From 7e39e32c2082b0eab2f8f5dc8dd447e2e038dddd Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Tue, 10 Nov 2026 21:01:55 +0000 Subject: [PATCH] Publish the validated Pages artifact without duplicate transfers --- .forgejo/workflows/deploy.yml | 36 +++++++++++++++++++++-------------- README.md | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 1b95141..e7fc01a 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -56,7 +56,7 @@ jobs: if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && contains(fromJSON('["andras","ruby336688"]'), github.actor) }} uses: https://github.com/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 with: - name: photos-validated-dist + name: pages-deploy-0 path: dist if-no-files-found: error retention-days: 1 @@ -73,16 +73,24 @@ jobs: # its result to Forgejo's dependent-job scheduler instead of repeating it. if: ${{ needs.validate.outputs.publish == 'success' }} steps: - - name: Download validated build - uses: https://github.com/actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a - with: - name: photos-validated-dist - path: dist - - - name: Upload static site artifact 1 - uses: https://github.com/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 - with: - name: pages-deploy-0 - path: dist - if-no-files-found: error - retention-days: 1 + # The Pages copier reads artifacts for this run after this job succeeds. + # Confirm the tested artifact instead of transferring the photos again. + - name: Release validated site to Pages + env: + ARTIFACTS_URL: ${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts + ARTIFACT_TOKEN: ${{ github.token }} + run: | + node --input-type=module <<'JS' + const response = await fetch(process.env.ARTIFACTS_URL, { + headers: { Authorization: `token ${process.env.ARTIFACT_TOKEN}` }, + signal: AbortSignal.timeout(10_000), + }); + if (!response.ok) throw new Error(`Artifact lookup failed: HTTP ${response.status}`); + const artifacts = await response.json(); + const site = artifacts.find((artifact) => + artifact.name === 'pages-deploy-0' && !artifact.expired && + String(artifact.run_id) === process.env.GITHUB_RUN_ID + ); + if (!site) throw new Error('The validated site artifact is missing.'); + console.log(`Validated artifact ${site.id} is ready for the Pages copier.`); + JS diff --git a/README.md b/README.md index 503a5fa..0238059 100644 --- a/README.md +++ b/README.md @@ -87,4 +87,4 @@ Review image changes after stripping because this rewrites the JPEG files. ## Deployment -The Forgejo workflow validates pull requests and trusted pushes with `npm ci`, `npm run lint:check`, `npm test`, `npm run build`, and a Playwright smoke test. CI previews the existing build for the smoke test instead of rebuilding. Trusted human pushes to `main` hand that validated `dist/` artifact to the deploy job and the Pages copier, which publishes it to `/pages/photos/` without another build. +The Forgejo workflow validates pull requests and trusted pushes with `npm ci`, `npm run lint:check`, `npm test`, `npm run build`, and a Playwright smoke test. CI previews the existing build for the smoke test instead of rebuilding. Trusted human pushes to `main` upload the validated `dist/` once as `pages-deploy-0`. The deploy job confirms that artifact exists for the current run, then the Pages copier publishes it to `/pages/photos/`. Deployment does not rebuild or transfer the photos between jobs.