Skip to content

Commit aa2ab93

Browse files
committed
More zip.
1 parent b60a70a commit aa2ab93

File tree

1 file changed

+19
-34
lines changed

1 file changed

+19
-34
lines changed

.github/workflows/push.yml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install a86 and langs
2525
run: |
2626
git clone https://github.com/cmsc430/a86.git
27-
git clone https://github.com/cmsc430/langs.git
27+
git clone https://github.com/cmsc430/langs.git
2828
raco pkg install --auto a86/
2929
raco pkg install --auto langs/
3030
- name: Build and test
@@ -42,48 +42,33 @@ jobs:
4242
-H "Authorization: Bearer $GITHUB_TOKEN" \
4343
https://api.github.com/repos/cmsc430/assignments/actions/workflows/push.yml/dispatches \
4444
-d '{"ref":"main"}'
45-
- name: Poll for zips
46-
id: poll_workflow
45+
- name: Get zips run ID
4746
env:
4847
GITHUB_TOKEN: ${{ secrets.PAT_ZIPS_WORKFLOW }}
4948
run: |
50-
MAX_ATTEMPTS=5 # Maximum polling attempts (2 minutes each = 10 minutes)
51-
ATTEMPT=0
52-
STATUS="in_progress"
53-
54-
sleep 10 # give request a chance to trigger
55-
while [[ "$ATTEMPT" -lt "$MAX_ATTEMPTS" && "$STATUS" != "completed" ]]; do
56-
echo "Polling attempt #$((ATTEMPT + 1))"
57-
ATTEMPT=$((ATTEMPT + 1))
58-
59-
response=$(curl -s \
60-
-H "Accept: application/vnd.github+json" \
61-
-H "Authorization: Bearer $GITHUB_TOKEN" \
62-
"https://api.github.com/repos/cmsc430/assignments/actions/runs?branch=main&status=success&per_page=1")
63-
64-
if [[ "$(echo "$response" | jq '.total_count')" -gt 0 ]]; then
65-
STATUS="completed"
66-
run_id=$(echo "$response" | jq -r '.workflow_runs[0].id')
67-
echo "RUN_ID=$run_id" >> $GITHUB_ENV
68-
else
69-
echo "Workflow not completed yet. Waiting for 2 minutes before next attempt."
70-
sleep 120 # Wait for 2 minutes before polling again
71-
fi
72-
done
73-
74-
if [[ "$STATUS" != "completed" ]]; then
75-
echo "Workflow did not complete in time. Exiting with failure."
76-
exit 1
77-
fi
49+
sleep 60 # give chance to finish
50+
response=$(curl -s \
51+
-H "Accept: application/vnd.github+json" \
52+
-H "Authorization: token $GITHUB_TOKEN" \
53+
"https://api.github.com/repos/cmsc430/assignments/actions/runs?branch=main&status=success&per_page=1")
54+
echo "Run response: $response"
55+
run_id=$(echo "$response" | jq -r '.workflow_runs[0].id')
56+
echo "RUN_ID=$run_id" >> $GITHUB_ENV
7857
- name: Download assignment zips
79-
if: success()
8058
env:
8159
GITHUB_TOKEN: ${{ secrets.PAT_ZIPS_WORKFLOW }}
8260
run: |
61+
response=$(curl -s \
62+
-H "Accept: application/vnd.github+json" \
63+
-H "Authorization: token $GITHUB_TOKEN" \
64+
https://api.github.com/repos/cmsc430/assignments/actions/runs/${{ env.RUN_ID }}/artifacts)
65+
echo "Run response: $response"
66+
download_url=$(echo "$response" | jq -r '.artifacts[0].archive_download_url)
67+
echo "Download URL: $download_url"
8368
curl -L \
8469
-H "Accept: application/vnd.github+json" \
85-
-H "Authorization: Bearer $GITHUB_TOKEN" \
86-
https://api.github.com/repos/cmsc430/assignments/actions/runs/${{ env.RUN_ID }}/artifacts \
70+
-H "Authorization: token $GITHUB_TOKEN" \
71+
$download_url
8772
-o artifacts.zip
8873
- name: Extract assignment zips
8974
if: success()

0 commit comments

Comments
 (0)