From 8eeec417edab1392725979855fe94f0a9b3e6b7d Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 1 Feb 2025 11:09:01 +0100 Subject: [PATCH 01/31] Tries logic in new files --- .github/scripts/pr-preview.mjs | 25 +++++++++++++++++++++++++ .github/workflows/pr-preview.yml | 32 ++++++++++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/scripts/pr-preview.mjs create mode 100644 .github/workflows/pr-preview.yml diff --git a/.github/scripts/pr-preview.mjs b/.github/scripts/pr-preview.mjs new file mode 100644 index 00000000000..1837640ba3e --- /dev/null +++ b/.github/scripts/pr-preview.mjs @@ -0,0 +1,25 @@ +#!/usr/bin/env zx +import 'zx/globals'; +import { config} from './commons.mjs' + +await generateProposedRulePages(config); +await generateTestCases(config); + +async function generateProposedRulePages({ tmpDir, rulesDir, glossaryDir, testAssetsDir }) { + await $`node ./node_modules/act-tools/dist/cli/rule-transform.js \ + --rulesDir "${rulesDir}" \ + --glossaryDir "${glossaryDir}" \ + --testAssetsDir "${testAssetsDir}" \ + --outDir "${tmpDir}" \ + --proposed + `; +} + +async function generateTestCases({ tmpDir, rulesDir, testAssetsDir }) { + await $`node ./node_modules/act-tools/dist/cli/build-examples.js \ + --rulesDir "${rulesDir}" \ + --testAssetsDir "${testAssetsDir}" \ + --outDir "${tmpDir}" \ + --proposed + `; +} diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 00000000000..ce7073aee00 --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,32 @@ +name: PR Preview +on: + pull_request: {} + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '16' + cache: npm + - uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm ci + - name: Checkout wcag-act-rules repo + uses: actions/checkout@v4 + with: + path: 'wcag-act-rules-tmp' + - name: Checkout or create PR branch + run: | + cd wcag-act-rules-tmp + git checkout -b ${{ github.event.pull_request.head.ref }} + cd .. + - name: Build and deploy WAI update + run: npm run pr:preview diff --git a/package.json b/package.json index fe780b9d4cd..e9431728f27 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,8 @@ "formatRulesDir": "prettier --write './_rules/**/*.md'", "format": "prettier --write *.{json,md,js,html,css,yml} './{__tests__,_rules,.github,pages,test-assets,test-utils,utils}/**/*.{json,md,js,html,css,yml}'", "test": "jest --coverage", - "build:wai": "zx .github/scripts/wai-build.mjs" + "build:wai": "zx .github/scripts/wai-build.mjs", + "pr:preview": "zx .github/scripts/pr-preview.mjs" }, "homepage": "https://github.com/act-rules/act-rules.github.io", "repository": { From 724c8aaa19b58c9eb050f7475ff8584cfc67be71 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 1 Feb 2025 11:48:47 +0100 Subject: [PATCH 02/31] Try process.env --- .github/scripts/commons.mjs | 1 + .github/workflows/pr-preview.yml | 13 +++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index d4cefe095f2..2140cfd1c98 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -19,6 +19,7 @@ export async function cloneWcagActRules({ tmpDir }) { } export async function createOrCheckoutBranch({ tmpDir }, branchName) { + branchName = process.env.BRANCH_NAME || 'main'; assert(branchName, 'branchName must be defined'); cd(tmpDir); try { diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index ce7073aee00..456df83e080 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -19,14 +19,7 @@ jobs: ${{ runner.os }}-node- - name: Install dependencies run: npm ci - - name: Checkout wcag-act-rules repo - uses: actions/checkout@v4 - with: - path: 'wcag-act-rules-tmp' - - name: Checkout or create PR branch - run: | - cd wcag-act-rules-tmp - git checkout -b ${{ github.event.pull_request.head.ref }} - cd .. - name: Build and deploy WAI update - run: npm run pr:preview + env: + branch_name: ${{ github.event.pull_request.head.ref }} + run: npm run build:wai From b61c565ce0dc6d9bb766e82b4bde46e34849c889 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 1 Feb 2025 12:10:29 +0100 Subject: [PATCH 03/31] Add createOrCheckoutBranch --- .github/scripts/commons.mjs | 2 +- .github/scripts/pr-preview.mjs | 5 ++++- .github/workflows/pr-preview.yml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index 2140cfd1c98..d62c14d92b6 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -13,7 +13,7 @@ export async function cloneWcagActRules({ tmpDir }) { await $`git clone \ --no-single-branch \ --branch main \ - https://github.com/w3c/wcag-act-rules.git ${tmpDir} \ + https://github.com/daniel-montalvo/wcag-act-rules.git ${tmpDir} \ --depth 1 `; } diff --git a/.github/scripts/pr-preview.mjs b/.github/scripts/pr-preview.mjs index 1837640ba3e..b46770a6e5e 100644 --- a/.github/scripts/pr-preview.mjs +++ b/.github/scripts/pr-preview.mjs @@ -1,9 +1,12 @@ #!/usr/bin/env zx import 'zx/globals'; -import { config} from './commons.mjs' +import { config, cloneWcagActRules, commitAndPush } from './commons.mjs' +await cloneWcagActRules(config); await generateProposedRulePages(config); await generateTestCases(config); +const commitMessage = (await $`git log -1 --pretty=%B`).stdout; +await commitAndPush(config, commitMessage); async function generateProposedRulePages({ tmpDir, rulesDir, glossaryDir, testAssetsDir }) { await $`node ./node_modules/act-tools/dist/cli/rule-transform.js \ diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 456df83e080..710d64361ae 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -22,4 +22,4 @@ jobs: - name: Build and deploy WAI update env: branch_name: ${{ github.event.pull_request.head.ref }} - run: npm run build:wai + run: npm run pr:preview From 1ce935864e886d515ad69a9ca0459878369ab8a8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 1 Feb 2025 12:11:38 +0100 Subject: [PATCH 04/31] Change rule title --- _rules/aria-attr-defined-5f99a7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_rules/aria-attr-defined-5f99a7.md b/_rules/aria-attr-defined-5f99a7.md index 9a9c7f32416..b61e37c3ef6 100755 --- a/_rules/aria-attr-defined-5f99a7.md +++ b/_rules/aria-attr-defined-5f99a7.md @@ -1,6 +1,6 @@ --- id: 5f99a7 -name: ARIA attribute is defined in WAI-ARIA +name: Daniel attribute is defined in WAI-ARIA rules_format: 1.1 rule_type: atomic description: | From a994cc7f0f882529de2343a0c82cc04d2024bd76 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 1 Feb 2025 12:13:28 +0100 Subject: [PATCH 05/31] Revert "Change rule title" This reverts commit 1ce935864e886d515ad69a9ca0459878369ab8a8. --- _rules/aria-attr-defined-5f99a7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_rules/aria-attr-defined-5f99a7.md b/_rules/aria-attr-defined-5f99a7.md index b61e37c3ef6..9a9c7f32416 100755 --- a/_rules/aria-attr-defined-5f99a7.md +++ b/_rules/aria-attr-defined-5f99a7.md @@ -1,6 +1,6 @@ --- id: 5f99a7 -name: Daniel attribute is defined in WAI-ARIA +name: ARIA attribute is defined in WAI-ARIA rules_format: 1.1 rule_type: atomic description: | From a765e09de8a95e8e42d3dd41573fd93535f79eec Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 1 Feb 2025 12:32:38 +0100 Subject: [PATCH 06/31] Write caps --- .github/scripts/pr-preview.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/pr-preview.mjs b/.github/scripts/pr-preview.mjs index b46770a6e5e..b08d52024bc 100644 --- a/.github/scripts/pr-preview.mjs +++ b/.github/scripts/pr-preview.mjs @@ -1,8 +1,9 @@ #!/usr/bin/env zx import 'zx/globals'; -import { config, cloneWcagActRules, commitAndPush } from './commons.mjs' +import { config, cloneWcagActRules, createOrCheckoutBranch, commitAndPush } from './commons.mjs' await cloneWcagActRules(config); +await createOrCheckoutBranch({ tmpDir }, branchName); await generateProposedRulePages(config); await generateTestCases(config); const commitMessage = (await $`git log -1 --pretty=%B`).stdout; From 57d87ed88dfacadd16759a0c1805492669a4642b Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 1 Feb 2025 13:12:12 +0100 Subject: [PATCH 07/31] Fix imports --- .github/scripts/commons.mjs | 3 ++- .github/scripts/pr-preview.mjs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index d62c14d92b6..c6a9698ab77 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -8,6 +8,8 @@ export const config = { testAssetsDir: `./test-assets/`, } +export const branchName = process.env.BRANCH_NAME || 'main'; + export async function cloneWcagActRules({ tmpDir }) { await $`rm -rf ${tmpDir}`; await $`git clone \ @@ -19,7 +21,6 @@ export async function cloneWcagActRules({ tmpDir }) { } export async function createOrCheckoutBranch({ tmpDir }, branchName) { - branchName = process.env.BRANCH_NAME || 'main'; assert(branchName, 'branchName must be defined'); cd(tmpDir); try { diff --git a/.github/scripts/pr-preview.mjs b/.github/scripts/pr-preview.mjs index b08d52024bc..d6d70cb69f0 100644 --- a/.github/scripts/pr-preview.mjs +++ b/.github/scripts/pr-preview.mjs @@ -1,9 +1,9 @@ #!/usr/bin/env zx import 'zx/globals'; -import { config, cloneWcagActRules, createOrCheckoutBranch, commitAndPush } from './commons.mjs' +import { config, cloneWcagActRules, createOrCheckoutBranch, commitAndPush, branchName } from './commons.mjs' await cloneWcagActRules(config); -await createOrCheckoutBranch({ tmpDir }, branchName); +await createOrCheckoutBranch(config, branchName); await generateProposedRulePages(config); await generateTestCases(config); const commitMessage = (await $`git log -1 --pretty=%B`).stdout; From ba99c19e16f74abb0fcfd116a297073eda788bf7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 11:24:14 +0100 Subject: [PATCH 08/31] no caps --- .github/scripts/commons.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index c6a9698ab77..a0829e85ca9 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -21,6 +21,7 @@ export async function cloneWcagActRules({ tmpDir }) { } export async function createOrCheckoutBranch({ tmpDir }, branchName) { + branchName = process.env.branch_name assert(branchName, 'branchName must be defined'); cd(tmpDir); try { From bb2cb83d36e9479a7af06ba4661e8d97f8b83e9a Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 13:17:56 +0100 Subject: [PATCH 09/31] Updates automation --- .github/scripts/commons.mjs | 2 +- .github/workflows/pr-preview.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index a0829e85ca9..9eccad6bd9e 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -21,7 +21,7 @@ export async function cloneWcagActRules({ tmpDir }) { } export async function createOrCheckoutBranch({ tmpDir }, branchName) { - branchName = process.env.branch_name + branchName = process.env.branch_name || 'main' assert(branchName, 'branchName must be defined'); cd(tmpDir); try { diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 710d64361ae..5fb6231b4b3 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -19,6 +19,10 @@ jobs: ${{ runner.os }}-node- - name: Install dependencies run: npm ci + - name: Configure git + run: | + git config --global user.name "daniel-montalvo" + git config --global user.email "users.noreply.github.com" - name: Build and deploy WAI update env: branch_name: ${{ github.event.pull_request.head.ref }} From e41357739adb1b7e3e8b6a052f82a24cd0caf3fb Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 13:28:48 +0100 Subject: [PATCH 10/31] Update workflow --- .github/workflows/pr-preview.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 5fb6231b4b3..f824e488eb7 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -5,6 +5,9 @@ on: jobs: dispatch: runs-on: ubuntu-latest + env: + branch_name: ${{ github.event.pull_request.head.ref }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -24,6 +27,7 @@ jobs: git config --global user.name "daniel-montalvo" git config --global user.email "users.noreply.github.com" - name: Build and deploy WAI update - env: - branch_name: ${{ github.event.pull_request.head.ref }} run: npm run pr:preview + - name: Comment on PR with preview link + run: | + gh pr comment ${{ github.event.pull_request.number }} --body "Preview ready at https://deploy-preview-${branch_name}--wai-wcag-act-rules.netlify.app" From 74f2b88f7d5f54880b8ffa21c909893f5a33221e Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 13:39:02 +0100 Subject: [PATCH 11/31] Update git config email --- .github/workflows/pr-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index f824e488eb7..09b78b61471 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -25,7 +25,7 @@ jobs: - name: Configure git run: | git config --global user.name "daniel-montalvo" - git config --global user.email "users.noreply.github.com" + git config --global user.email "users.noreply@github.com" - name: Build and deploy WAI update run: npm run pr:preview - name: Comment on PR with preview link From 7b718e5e7229d2498d3314a56ecfb4563d6284f5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 13:47:44 +0100 Subject: [PATCH 12/31] Update git config email --- .github/workflows/pr-preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 09b78b61471..eb4f44df3c8 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -24,6 +24,7 @@ jobs: run: npm ci - name: Configure git run: | + git config --global url."https://daniel-montalvo/wcag-act-rules:${{ secrets.PAT_TOKEN }}@github.com".insteadOf "https://github.com" git config --global user.name "daniel-montalvo" git config --global user.email "users.noreply@github.com" - name: Build and deploy WAI update From 7539f330909c6bc262ec5926fb7652962f163e06 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 13:51:34 +0100 Subject: [PATCH 13/31] ; --- .github/workflows/pr-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index eb4f44df3c8..e5c1f99c171 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -24,7 +24,7 @@ jobs: run: npm ci - name: Configure git run: | - git config --global url."https://daniel-montalvo/wcag-act-rules:${{ secrets.PAT_TOKEN }}@github.com".insteadOf "https://github.com" + git config --global url."https://daniel-montalvo:wcag-act-rules:${{ secrets.PAT_TOKEN }}@github.com".insteadOf "https://github.com" git config --global user.name "daniel-montalvo" git config --global user.email "users.noreply@github.com" - name: Build and deploy WAI update From 9d3aed7b66e7bc1cdd74d00f8e280bf21136fb0d Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 14:00:24 +0100 Subject: [PATCH 14/31] Change auth --- .github/workflows/pr-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index e5c1f99c171..f4a281f4a63 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest env: branch_name: ${{ github.event.pull_request.head.ref }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 980f7aa1f0c4c588b370e3d0f3b004376f1b9417 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 14:11:31 +0100 Subject: [PATCH 15/31] Update auth --- .github/workflows/pr-preview.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index f4a281f4a63..a2abbb6de7b 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -22,11 +22,6 @@ jobs: ${{ runner.os }}-node- - name: Install dependencies run: npm ci - - name: Configure git - run: | - git config --global url."https://daniel-montalvo:wcag-act-rules:${{ secrets.PAT_TOKEN }}@github.com".insteadOf "https://github.com" - git config --global user.name "daniel-montalvo" - git config --global user.email "users.noreply@github.com" - name: Build and deploy WAI update run: npm run pr:preview - name: Comment on PR with preview link From 050ed939ae9b8fae055f2928ba5b98c178710cf9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 14:15:09 +0100 Subject: [PATCH 16/31] Update auth --- .github/workflows/pr-preview.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index a2abbb6de7b..bb172d37aa4 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -22,6 +22,11 @@ jobs: ${{ runner.os }}-node- - name: Install dependencies run: npm ci + - name: Configure git + run: | + + git config --global user.name "daniel-montalvo" + git config --global user.email "users.noreply@github.com" - name: Build and deploy WAI update run: npm run pr:preview - name: Comment on PR with preview link From 43f47bcc73473c09cc4b473b72e1d590c38f2161 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Feb 2025 13:01:44 +0100 Subject: [PATCH 17/31] Repo secrets --- .github/workflows/pr-preview.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index bb172d37aa4..4ba47b07275 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -20,13 +20,14 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- + - run: git config --global url."https://github.com/".insteadOf ssh://git@github.com/ - name: Install dependencies run: npm ci - name: Configure git run: | - - git config --global user.name "daniel-montalvo" - git config --global user.email "users.noreply@github.com" + git config --global url."https://${{ secrets.WAI_GIT_NAME }}:${{ secrets.WAI_GIT_ACCESS_TOKEN }}@github.com".insteadOf "https://github.com" + git config --global user.name "${{ secrets.WAI_GIT_NAME }}" + git config --global user.email "${{ secrets.WAI_GIT_EMAIL }}" - name: Build and deploy WAI update run: npm run pr:preview - name: Comment on PR with preview link From d13e6f89c730f38da25511637a8cb9eddd0f1722 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Feb 2025 13:43:21 +0100 Subject: [PATCH 18/31] Auth for gh cli --- .github/workflows/pr-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 4ba47b07275..8723e941d79 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest env: branch_name: ${{ github.event.pull_request.head.ref }} - GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} + GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From ee50ffcf4fc3d2a984e9a6f17d630972a6a074e6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Feb 2025 14:52:16 +0100 Subject: [PATCH 19/31] Specify permissions --- .github/workflows/pr-preview.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 8723e941d79..84c16a3ac7c 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -5,6 +5,8 @@ on: jobs: dispatch: runs-on: ubuntu-latest + permissions: + pull-requests: write env: branch_name: ${{ github.event.pull_request.head.ref }} GH_TOKEN: ${{ github.token }} From eff5804d07947cc8e89ec9e07ee1dd5c3f1c470b Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Feb 2025 15:08:02 +0100 Subject: [PATCH 20/31] Right reference to branch_name --- .github/workflows/pr-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 84c16a3ac7c..c482e71e692 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -34,4 +34,4 @@ jobs: run: npm run pr:preview - name: Comment on PR with preview link run: | - gh pr comment ${{ github.event.pull_request.number }} --body "Preview ready at https://deploy-preview-${branch_name}--wai-wcag-act-rules.netlify.app" + gh pr comment ${{ github.event.pull_request.number }} --body "Preview ready at https://deploy-preview-${{ env.branch_name }}--wai-wcag-act-rules.netlify.app" From d6d75ce928df723465835669b32ab469642ed2fe Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Feb 2025 16:02:20 +0100 Subject: [PATCH 21/31] Org should be W3C --- .github/scripts/commons.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index 9eccad6bd9e..056d5651372 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -15,7 +15,7 @@ export async function cloneWcagActRules({ tmpDir }) { await $`git clone \ --no-single-branch \ --branch main \ - https://github.com/daniel-montalvo/wcag-act-rules.git ${tmpDir} \ + https://github.com/w3c/wcag-act-rules.git ${tmpDir} \ --depth 1 `; } From 9fbecb024059d75dc6a5d26dac972f48378a3541 Mon Sep 17 00:00:00 2001 From: Daniel Montalvo <49305434+daniel-montalvo@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:15:51 +0100 Subject: [PATCH 22/31] Update .github/scripts/commons.mjs Co-authored-by: Jean-Yves Moyen --- .github/scripts/commons.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index 056d5651372..908314475e0 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -8,7 +8,7 @@ export const config = { testAssetsDir: `./test-assets/`, } -export const branchName = process.env.BRANCH_NAME || 'main'; +export const branchName = process.env.BRANCH_NAME ?? 'main'; export async function cloneWcagActRules({ tmpDir }) { await $`rm -rf ${tmpDir}`; From 31198f000ae780def5ad5c81cf6da987583991f1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Feb 2025 16:23:28 +0100 Subject: [PATCH 23/31] Remove assertion --- .github/scripts/commons.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index 908314475e0..ae11882f537 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -22,7 +22,6 @@ export async function cloneWcagActRules({ tmpDir }) { export async function createOrCheckoutBranch({ tmpDir }, branchName) { branchName = process.env.branch_name || 'main' - assert(branchName, 'branchName must be defined'); cd(tmpDir); try { await $`git checkout ${branchName}`; From ccef4c2285906cc8932ffbe93ea58bb071f0b04b Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Feb 2025 18:21:34 +0100 Subject: [PATCH 24/31] Try relying on const value --- .github/scripts/commons.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index ae11882f537..0235fb71e0c 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -21,7 +21,6 @@ export async function cloneWcagActRules({ tmpDir }) { } export async function createOrCheckoutBranch({ tmpDir }, branchName) { - branchName = process.env.branch_name || 'main' cd(tmpDir); try { await $`git checkout ${branchName}`; From fbeb0911b98e6575b5e6b85c9fc35cbe37b57a39 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Feb 2025 18:36:16 +0100 Subject: [PATCH 25/31] Define `nv` at a step level --- .github/workflows/pr-preview.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index c482e71e692..ff682cfaf82 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -6,10 +6,7 @@ jobs: dispatch: runs-on: ubuntu-latest permissions: - pull-requests: write - env: - branch_name: ${{ github.event.pull_request.head.ref }} - GH_TOKEN: ${{ github.token }} + pull-requests: write steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -32,6 +29,12 @@ jobs: git config --global user.email "${{ secrets.WAI_GIT_EMAIL }}" - name: Build and deploy WAI update run: npm run pr:preview + env: + branch_name: ${{ github.event.pull_request.head.ref }} + GH_TOKEN: ${{ github.token }} - name: Comment on PR with preview link run: | gh pr comment ${{ github.event.pull_request.number }} --body "Preview ready at https://deploy-preview-${{ env.branch_name }}--wai-wcag-act-rules.netlify.app" + env: + branch_name: ${{ github.event.pull_request.head.ref }} + GH_TOKEN: ${{ github.token }} From da88433578d8cc2062b7b4596ea5661173c95ff1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 4 Feb 2025 12:58:38 +0100 Subject: [PATCH 26/31] Revert "Define `nv` at a step level" This reverts commit fbeb0911b98e6575b5e6b85c9fc35cbe37b57a39. --- .github/workflows/pr-preview.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index ff682cfaf82..2bfbecb750e 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -7,6 +7,9 @@ jobs: runs-on: ubuntu-latest permissions: pull-requests: write + env: + branch_name: ${{ github.event.pull_request.head.ref }} + GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -29,12 +32,6 @@ jobs: git config --global user.email "${{ secrets.WAI_GIT_EMAIL }}" - name: Build and deploy WAI update run: npm run pr:preview - env: - branch_name: ${{ github.event.pull_request.head.ref }} - GH_TOKEN: ${{ github.token }} - name: Comment on PR with preview link run: | gh pr comment ${{ github.event.pull_request.number }} --body "Preview ready at https://deploy-preview-${{ env.branch_name }}--wai-wcag-act-rules.netlify.app" - env: - branch_name: ${{ github.event.pull_request.head.ref }} - GH_TOKEN: ${{ github.token }} From 39a0c3ecc95fee77e613c389cb5e8a07dcf44352 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 4 Feb 2025 13:12:39 +0100 Subject: [PATCH 27/31] Tries pull_request_target --- .github/workflows/pr-preview.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 2bfbecb750e..dd46bf5f295 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -1,17 +1,23 @@ name: PR Preview + on: - pull_request: {} + pull_request_target: + types: [opened, synchronize, reopened] jobs: dispatch: runs-on: ubuntu-latest permissions: + contents: read pull-requests: write env: branch_name: ${{ github.event.pull_request.head.ref }} GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/setup-node@v4 with: node-version: '16' From 9599ba6e0d4133e57a27bb596d7db053ce8de5b2 Mon Sep 17 00:00:00 2001 From: Daniel Montalvo <49305434+daniel-montalvo@users.noreply.github.com> Date: Fri, 7 Feb 2025 11:37:50 +0100 Subject: [PATCH 28/31] Update .github/scripts/commons.mjs Co-authored-by: Jean-Yves Moyen --- .github/scripts/commons.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/commons.mjs b/.github/scripts/commons.mjs index 0235fb71e0c..d4f679b622c 100644 --- a/.github/scripts/commons.mjs +++ b/.github/scripts/commons.mjs @@ -20,7 +20,7 @@ export async function cloneWcagActRules({ tmpDir }) { `; } -export async function createOrCheckoutBranch({ tmpDir }, branchName) { +export async function createOrCheckoutBranch({ tmpDir }) { cd(tmpDir); try { await $`git checkout ${branchName}`; From 342fa89b7e6de17de007e86ecd81a6100ed5b3bf Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 7 Feb 2025 10:49:13 +0000 Subject: [PATCH 29/31] Revert "Tries pull_request_target" This reverts commit 39a0c3ecc95fee77e613c389cb5e8a07dcf44352. --- .github/workflows/pr-preview.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index dd46bf5f295..2bfbecb750e 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -1,23 +1,17 @@ name: PR Preview - on: - pull_request_target: - types: [opened, synchronize, reopened] + pull_request: {} jobs: dispatch: runs-on: ubuntu-latest permissions: - contents: read pull-requests: write env: branch_name: ${{ github.event.pull_request.head.ref }} GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/setup-node@v4 with: node-version: '16' From 5af998491b803d9cecfc32d1519095af806027b8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 7 Feb 2025 10:53:18 +0000 Subject: [PATCH 30/31] Add gh_repo setting --- .github/workflows/pr-preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 2bfbecb750e..36ce93ae2d4 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -9,6 +9,7 @@ jobs: pull-requests: write env: branch_name: ${{ github.event.pull_request.head.ref }} + gh_repo: act-rules/act-rules.github.io GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 From f78fcd8f2c2ddfdc59cde677f2b0128464ed5664 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 7 Feb 2025 10:59:43 +0000 Subject: [PATCH 31/31] workflow_dispatch --- .github/workflows/pr-preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 36ce93ae2d4..3000acf840e 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -1,6 +1,7 @@ name: PR Preview on: pull_request: {} + workflow_dispatch: jobs: dispatch: