Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ on:
push:
branches:
- main


concurrency:
group: pages
cancel-in-progress: false

permissions:
contents: read
id-token: write
Expand Down Expand Up @@ -31,7 +35,9 @@ jobs:
- name : Upload artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
name: github-pages
name: github-pages-${{ github.run_attempt }}
path: site/_site
- name: Deploy to GitHub Pages from artifacts
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
with:
artifact_name: github-pages-${{ github.run_attempt }}
13 changes: 13 additions & 0 deletions OWNER-CHEATSHEET.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ delete retained intents or overwrite a partial branch to force recovery.
To stop an active run, cancel it or withdraw the command as well as disabling
the activation variable. No activation or live coding run was performed here.

## Website deployments

The [Pages workflow](./.github/workflows/github-pages.yml) deploys `main`.
Deployments share one concurrency group without cancelling an active publish.
Within each workflow run, every attempt uploads and deploys its matching
`github-pages-<attempt>` artifact, so retained earlier attempts do not make
artifact selection ambiguous.

Before retrying a failed deployment, check that a newer successful run has not
superseded it. A rerun uses its original workflow version: after a deployment
fix is merged, follow the new default-branch run instead of retrying an older
failure. No artifact deletion or coding-pilot activation is needed.

## If something stalls

| Symptom | Safe next step |
Expand Down
45 changes: 45 additions & 0 deletions tools/tests/pages-workflow.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import assert from "node:assert/strict";
import fs from "node:fs";
import test from "node:test";
import { parse } from "yaml";

const workflow = parse(fs.readFileSync(new URL("../../.github/workflows/github-pages.yml", import.meta.url), "utf8"));

test("Pages deployments share a queue without cancelling an active publish", () => {
assert.deepEqual(workflow.concurrency, { group: "pages", "cancel-in-progress": false });
assert.equal(workflow.jobs.deploy.concurrency, undefined);
});

test("Pages reruns select only their own artifact while retaining earlier attempts", () => {
const uploads = workflow.jobs.deploy.steps.filter(step => step.uses?.startsWith("actions/upload-pages-artifact@"));
const deployments = workflow.jobs.deploy.steps.filter(step => step.uses?.startsWith("actions/deploy-pages@"));
assert.equal(uploads.length, 1);
assert.equal(deployments.length, 1);
const upload = uploads[0];
const deploy = deployments[0];
assert.equal(upload.with.name, "github-pages-${{ github.run_attempt }}");
assert.equal(deploy.with.artifact_name, upload.with.name);
assert.equal(upload.with.path, "site/_site");

const artifactName = (template, attempt) => template.replace("${{ github.run_attempt }}", String(attempt));
const artifacts = [1, 2, 3].map(attempt => ({
id: attempt, name: artifactName(upload.with.name, attempt),
}));
assert.equal(new Set(artifacts.map(artifact => artifact.name)).size, 3);
for (const attempt of [1, 2, 3]) {
const selected = artifacts.filter(artifact => artifact.name === artifactName(deploy.with.artifact_name, attempt));
assert.deepEqual(selected.map(artifact => artifact.id), [attempt]);
}
});

test("Pages deployment keeps its main-only trigger and existing permissions", () => {
assert.deepEqual(workflow.on, { push: { branches: ["main"] } });
assert.deepEqual(workflow.permissions, { contents: "read", "id-token": "write", pages: "write" });
assert.equal(workflow.jobs.deploy.permissions, undefined);
for (const step of workflow.jobs.deploy.steps.filter(step => step.uses)) {
assert.match(step.uses, /^[\w-]+\/[\w-]+@[a-f0-9]{40}$/);
}
});
Loading