chore: fix env-file download to not require actions read permission - #42
Conversation
PR #41 merged a version that requested actions: read and used gh run download. Reusable workflows can't request a permission the caller doesn't grant, so callers cap the nested job at actions: none and the workflow is rejected as invalid (deploy job "requesting actions: read, but is only allowed actions: none"). Switch back to actions/download-artifact@v4, which authenticates via the injected runtime token and needs no actions: permission, and get retry behavior by re-running the step up to 3 times with backoff (continue-on-error, gated on the prior attempt's outcome). deployment.yaml keeps a single stable env_artifact outcome (a final step that succeeds iff a .env was downloaded) so the existing downstream gates are unchanged and a genuinely absent artifact still skips cleanly.
Greptile SummaryThis PR fixes a reusable-workflow breakage introduced in #41 by replacing
Confidence Score: 4/5Safe to merge — the permission regression is correctly fixed and the retry/outcome chain logic is sound in both workflows. The core fix is correct and well-reasoned. The retry chain logic is correctly wired in both files: each subsequent attempt is gated on the previous outcome, the Both files are straightforward; Important Files Changed
Reviews (1): Last reviewed commit: "chore: fix env-file download to not requ..." | Re-trigger Greptile |
| - name: Download .env artifact (attempt 3) | ||
| id: dl3 | ||
| if: ${{ inputs.deploy_type != 'release-only' && steps.dl1.outcome == 'failure' && steps.dl2.outcome == 'failure' }} | ||
| continue-on-error: true | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: env-file | ||
| path: ${{ runner.temp }}/env-file |
There was a problem hiding this comment.
Unused step id on final download attempt
id: dl3 is declared on the third download attempt but never referenced downstream — the env_artifact step uses a find check rather than inspecting steps.dl3.outcome. The id has no effect and can be dropped to reduce noise, though it is harmless as-is.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| sleep 15 | ||
| done | ||
| echo "env-file artifact not downloadable after 5 attempts; deploy will proceed without attached env secrets" | ||
| if find "${{ runner.temp }}/env-file" -name '.env' -type f | grep -q .; then |
There was a problem hiding this comment.
Suppressing stderr from
find keeps the log clean when all download attempts fail and the directory was never created — the existing logic (grep -q . exits 1, then exit 1) is already correct, but without redirection the No such file or directory message appears in CI output alongside the intentional "env-file not downloaded" message.
| if find "${{ runner.temp }}/env-file" -name '.env' -type f | grep -q .; then | |
| if find "${{ runner.temp }}/env-file" -name '.env' -type f 2>/dev/null | grep -q .; then |
Summary
Follow-up to #41. That PR merged a version of the
env-filedownload that requestedactions: readand usedgh run download, which makes both reusable workflows invalid for every caller. Switch toactions/download-artifact@v4re-run up to 3 times with backoff — the runtime-token auth needs noactions:permission, so callers work unchanged.Why
#41 broke callers with:
A reusable workflow cannot request a permission the caller's job doesn't already grant. Callers set top-level
permissions:withoutactions:, so the nested job is capped atactions: noneand the whole workflow is rejected.gh run downloadneedsactions: read;actions/download-artifact@v4does not (it authenticates via the injected run-scoped runtime token) — which is why the pre-#41 code worked without anyactions:permission.The original goal still holds: on ephemeral ARC pods the Artifacts v4 results service is occasionally not yet consistent for the run when the pod starts, returning a transient 404. Re-running the download absorbs that window.
Changes
gh run downloadwithactions/download-artifact@v4, re-run up to 3 times (continue-on-error, gated on the prior attempt's outcome, 15s then 30s backoff). Noactions:permission required.deployment.yaml: a finalenv_artifactstep yields one stable outcome (success iff a.envwas downloaded), so the existing downstreamoutcome == 'success'gates are unchanged and a genuinely absent artifact still skips cleanly.actions: readlines added in chore: retry env-file artifact download on ARC to fix flaky 404 #41 from both jobs.QA Report
Integration Tests