Publish the validated Pages artifact without duplicate transfers
This commit is contained in:
parent
d47162cc90
commit
7e39e32c20
2 changed files with 23 additions and 15 deletions
|
|
@ -56,7 +56,7 @@ jobs:
|
||||||
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && contains(fromJSON('["andras","ruby336688"]'), github.actor) }}
|
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
|
uses: https://github.com/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5
|
||||||
with:
|
with:
|
||||||
name: photos-validated-dist
|
name: pages-deploy-0
|
||||||
path: dist
|
path: dist
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
@ -73,16 +73,24 @@ jobs:
|
||||||
# its result to Forgejo's dependent-job scheduler instead of repeating it.
|
# its result to Forgejo's dependent-job scheduler instead of repeating it.
|
||||||
if: ${{ needs.validate.outputs.publish == 'success' }}
|
if: ${{ needs.validate.outputs.publish == 'success' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Download validated build
|
# The Pages copier reads artifacts for this run after this job succeeds.
|
||||||
uses: https://github.com/actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
|
# Confirm the tested artifact instead of transferring the photos again.
|
||||||
with:
|
- name: Release validated site to Pages
|
||||||
name: photos-validated-dist
|
env:
|
||||||
path: dist
|
ARTIFACTS_URL: ${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts
|
||||||
|
ARTIFACT_TOKEN: ${{ github.token }}
|
||||||
- name: Upload static site artifact 1
|
run: |
|
||||||
uses: https://github.com/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5
|
node --input-type=module <<'JS'
|
||||||
with:
|
const response = await fetch(process.env.ARTIFACTS_URL, {
|
||||||
name: pages-deploy-0
|
headers: { Authorization: `token ${process.env.ARTIFACT_TOKEN}` },
|
||||||
path: dist
|
signal: AbortSignal.timeout(10_000),
|
||||||
if-no-files-found: error
|
});
|
||||||
retention-days: 1
|
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
|
||||||
|
|
|
||||||
|
|
@ -87,4 +87,4 @@ Review image changes after stripping because this rewrites the JPEG files.
|
||||||
|
|
||||||
## Deployment
|
## 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.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue