Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(workflows/sync-upstream): fix nix command return status checking #99

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/sync-upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,32 @@ jobs:
vendor=
until [ "$retry_count" -ge "$max_retries" ]; do
vendor="$(nix --log-format raw build .#$project 2>&1 | grep "got: " | awk '/got: / {print $NF}' || echo '')"
vendor_fetch_status=$?
if [ -n "$vendor" ]; then
# If $vendor is not empty, extraction succeeded
vendor_fetch_status=0
break
fi
retry_count=$((retry_count + 1))
echo "Retrying nix command and awk extraction ($retry_count/$max_retries)..."
sleep 3
done
# If the vendor is still empty after max retries, exit with failure
if [ -z "$vendor" ]; then
if [ "$vendor_fetch_status" -ne 0 ]; then
echo "nix command failed with status $vendor_fetch_status."
echo "awk extraction failed after $max_retries attempts."
exit 1
fi
# Continue with script execution using $vendor
echo "Vendor extraction succeeded: $vendor"


if [ -z "$vendor" ]; then
# if $vendor is empty
# use original vendorHash
vendor="$(jq -r '.vendorHash' $project/metadata.json)"
fi

# Continue with script execution using $vendor
echo "Vendor extraction succeeded: $vendor"

# Update vendorHash in metadata.json
echo "Final vendor value: '$vendor'"
jq --arg vendor "$vendor" \
'.vendorHash = $vendor' \
./$project/metadata.json | tee ./$project/metadata.json.tmp
Expand Down