Skip to content

Commit 485e01b

Browse files
authored
Update deploy workflow to use Eleventy build process (#3955)
This replaces the existing files under `.github` (both `workflows` and `scripts`) with a new workflow using the Eleventy build process. - Current behavior RE `conformance-challenges`, `guidelines`, and `requirements` directories is retained - Also ensures necessary CSS is updated under `guidelines` - `techniques`, `understanding`, and `working-examples` are now generated by the Eleventy build process This has positive side effects over what's currently seen on github.io: - Fixes broken styles - Updates any auto-generated cross-links to guidelines to point to 2.2 editor's draft instead of 2.1 - All of the fixes mentioned in #3917
1 parent b2dc10a commit 485e01b

File tree

7 files changed

+72
-83
lines changed

7 files changed

+72
-83
lines changed

.github/scripts/deploy.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/11ty-publish.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
# Reference documentation: https://docs.github.com/en/actions/reference
4+
5+
# See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags
6+
on:
7+
push:
8+
branches: [main]
9+
10+
jobs:
11+
main:
12+
name: deploy (11ty)
13+
runs-on: ubuntu-20.04
14+
steps:
15+
- name: Checkout the repository
16+
uses: actions/checkout@v4
17+
- name: Checkout gh-pages
18+
uses: actions/checkout@v4
19+
with:
20+
ref: gh-pages
21+
path: _site
22+
- name: Install Node.js and dependencies
23+
uses: actions/setup-node@v4
24+
with:
25+
cache: npm
26+
node-version-file: '.nvmrc'
27+
- name: Build
28+
env:
29+
WCAG_MODE: editors
30+
run: |
31+
npm i
32+
npm run build
33+
cp guidelines/guidelines.css guidelines/relative-luminance.html _site/guidelines/22
34+
curl https://labs.w3.org/spec-generator/?type=respec"&"url=https://raw.githack.com/$GITHUB_REPOSITORY/main/guidelines/index.html -o _site/guidelines/22/index.html -f --retry 3
35+
curl https://labs.w3.org/spec-generator/?type=respec"&"url=https://raw.githack.com/$GITHUB_REPOSITORY/main/requirements/22/index.html -o _site/requirements/22/index.html -f --retry 3
36+
curl https://labs.w3.org/spec-generator/?type=respec"&"url=https://raw.githack.com/$GITHUB_REPOSITORY/main/conformance-challenges/index.html -o _site/conformance-challenges/index.html -f --retry 3
37+
- name: Push
38+
working-directory: _site
39+
run: |
40+
git config user.email 87540780+w3cgruntbot@users.noreply.github.com
41+
git config user.name w3cgruntbot
42+
git add -A .
43+
git commit -m ":robot: Deploy to GitHub Pages: $GITHUB_SHA from branch $GITHUB_REF"
44+
git push origin gh-pages

.github/workflows/manual-publish.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

11ty/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ Indicates top-level path of W3C CVS checkout, for WAI site updates (via `publish
4040

4141
### `WCAG_VERSION`
4242

43-
**Usage context:** `publish-w3c` script only;
44-
this should currently not be changed, pending future improvements to `21` support.
43+
**Usage context:** currently this should not be changed, pending future improvements to `21` support
4544

46-
Indicates WCAG version being built, in `XY` format (i.e. no `.`)
45+
Indicates WCAG version being built, in `XY` format (i.e. no `.`).
46+
Influences base URLs for links to guidelines, techniques, and understanding pages.
4747

4848
**Default:** `22`
4949

5050
### `WCAG_MODE`
5151

52-
**Usage context:** should not need to be used manually except in specific testing scenarios
52+
**Usage context:** should not need to be set manually except in specific testing scenarios
5353

5454
Influences base URLs for links to guidelines, techniques, and understanding pages.
5555
Typically set by specific npm scripts or CI processes.
@@ -60,6 +60,15 @@ Possible values:
6060
- `editors` - Sets base URLs appropriate for `gh-pages` publishing; used by deploy action
6161
- `publication` - Sets base URLs appropriate for WAI site publishing; used by `publish-w3c` script
6262

63+
### `GITHUB_REPOSITORY`
64+
65+
**Usage context:** Automatically set during GitHub workflows; should not need to be set manually
66+
67+
Influences base URLs for links to guidelines, techniques, and understanding pages,
68+
when `WCAG_MODE=editors` is also set.
69+
70+
**Default:** `w3c/wcag`
71+
6372
## Other points of interest
6473

6574
- The main configuration can be found in top-level `eleventy.config.ts`

11ty/cp-cvs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/** @fileoverview script to copy already-built output to CVS subfolders */
22

3-
import { copyFile, unlink } from "fs/promises";
43
import { glob } from "glob";
54
import { mkdirp } from "mkdirp";
65

6+
import { copyFile, unlink } from "fs/promises";
77
import { dirname, join } from "path";
88

9+
import { assertIsWcagVersion } from "./guidelines";
10+
911
const outputBase = "_site";
1012
const cvsBase = process.env.WCAG_CVSDIR || "../../../w3ccvs";
1113
const wcagVersion = process.env.WCAG_VERSION || "22";
14+
assertIsWcagVersion(wcagVersion);
1215
const wcagBase = `${cvsBase}/WWW/WAI/WCAG${wcagVersion}`;
1316

1417
// Map (git) sources to (CVS) destinations, since some don't match case-sensitively

11ty/guidelines.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { flattenDomFromFile, load } from "./cheerio";
88
import { generateId } from "./common";
99

1010
export type WcagVersion = "20" | "21" | "22";
11-
function assertIsWcagVersion(v: string): asserts v is WcagVersion {
11+
export function assertIsWcagVersion(v: string): asserts v is WcagVersion {
1212
if (!/^2[012]$/.test(v)) throw new Error(`Unexpected version found: ${v}`);
1313
}
1414

eleventy.config.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import compact from "lodash-es/compact";
33
import { copyFile } from "fs/promises";
44

55
import { CustomLiquid } from "11ty/CustomLiquid";
6-
import { actRules, getFlatGuidelines, getPrinciples } from "11ty/guidelines";
6+
import { actRules, assertIsWcagVersion, getFlatGuidelines, getPrinciples } from "11ty/guidelines";
77
import {
88
getFlatTechniques,
99
getTechniqueAssociations,
@@ -15,7 +15,8 @@ import { generateUnderstandingNavMap, getUnderstandingDocs } from "11ty/understa
1515
import type { EleventyContext, EleventyData, EleventyEvent } from "11ty/types";
1616

1717
/** Version of WCAG to build */
18-
const version = "22";
18+
const version = process.env.WCAG_VERSION || "22";
19+
assertIsWcagVersion(version);
1920

2021
const principles = await getPrinciples();
2122
const flatGuidelines = getFlatGuidelines(principles);
@@ -45,6 +46,8 @@ export type GlobalData = EleventyData &
4546
isUnderstanding?: boolean;
4647
};
4748

49+
const [GH_ORG, GH_REPO] = (process.env.GITHUB_REPOSITORY || "w3c/wcag").split("/");
50+
4851
const baseUrls = {
4952
guidelines: `https://www.w3.org/TR/WCAG${version}/`,
5053
techniques: "/techniques/",
@@ -53,9 +56,11 @@ const baseUrls = {
5356

5457
if (process.env.WCAG_MODE === "editors") {
5558
// For pushing to gh-pages
56-
baseUrls.guidelines = "https://w3c.github.io/wcag/guidelines/";
57-
baseUrls.techniques = "https://w3c.github.io/wcag/techniques/";
58-
baseUrls.understanding = "https://w3c.github.io/wcag/understanding/";
59+
baseUrls.guidelines = `https://${GH_ORG}.github.io/${GH_REPO}/guidelines/${
60+
version === "21" ? "" : `${version}/`
61+
}`;
62+
baseUrls.techniques = `https://${GH_ORG}.github.io/${GH_REPO}/techniques/`;
63+
baseUrls.understanding = `https://${GH_ORG}.github.io/${GH_REPO}/understanding/`;
5964
} else if (process.env.WCAG_MODE === "publication") {
6065
// For pushing to W3C site
6166
baseUrls.guidelines = `https://www.w3.org/TR/WCAG${version}/`;

0 commit comments

Comments
 (0)