Skip to content

Commit 04534cd

Browse files
committed
fix: clear stale pages artifacts before deploy
1 parent e01f0a4 commit 04534cd

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
permissions:
9292
pages: write
9393
id-token: write
94+
actions: write
9495
environment:
9596
name: github-pages
9697
url: ${{ steps.deployment.outputs.page_url }}
@@ -103,6 +104,20 @@ jobs:
103104
- name: Generate the roster page
104105
run: python scripts/build_site.py
105106

107+
# Re-runs keep artifacts from earlier attempts, and deploy-pages
108+
# refuses when it finds more than one "github-pages" artifact in a
109+
# run — so drop any leftovers before uploading a fresh one.
110+
- name: Drop stale github-pages artifacts from this run
111+
env:
112+
GH_TOKEN: ${{ github.token }}
113+
run: |
114+
gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
115+
--jq '.artifacts[] | select(.name == "github-pages") | .id' \
116+
| while read -r id; do
117+
echo "deleting stale artifact $id"
118+
gh api -X DELETE "repos/${{ github.repository }}/actions/artifacts/$id"
119+
done || true
120+
106121
# Deploy https://comppsyunion.github.io/github-playground/ straight
107122
# from the workflow (Pages source: GitHub Actions). The freshly
108123
# built docs/ directory is uploaded as the artifact — nothing is

0 commit comments

Comments
 (0)