File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1010
1111permissions :
1212 contents : read
13+ actions : write
1314 pages : write
1415 id-token : write
1516
6364 name : github-pages
6465 url : ${{ steps.deployment.outputs.page_url }}
6566 steps :
67+ - name : Deduplicate artifacts
68+ uses : actions/github-script@v7
69+ with :
70+ script : |
71+ const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
72+ owner: context.repo.owner,
73+ repo: context.repo.repo,
74+ run_id: context.runId,
75+ });
76+ const pages = artifacts.data.artifacts
77+ .filter(a => a.name === 'github-pages')
78+ .sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
79+ for (const dup of pages.slice(1)) {
80+ console.log(`Deleting duplicate artifact ${dup.id} (created ${dup.created_at})`);
81+ await github.rest.actions.deleteArtifact({
82+ owner: context.repo.owner,
83+ repo: context.repo.repo,
84+ artifact_id: dup.id,
85+ });
86+ }
87+ console.log(`Kept artifact ${pages[0].id} (created ${pages[0].created_at})`);
88+
6689 - name : Deploy to GitHub Pages
6790 id : deployment
6891 uses : actions/deploy-pages@v4
You can’t perform that action at this time.
0 commit comments