Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8eeec41
Tries logic in new files
daniel-montalvo Feb 1, 2025
724c8aa
Try process.env
daniel-montalvo Feb 1, 2025
b61c565
Add createOrCheckoutBranch
daniel-montalvo Feb 1, 2025
1ce9358
Change rule title
daniel-montalvo Feb 1, 2025
a994cc7
Revert "Change rule title"
daniel-montalvo Feb 1, 2025
a765e09
Write caps
daniel-montalvo Feb 1, 2025
57d87ed
Fix imports
daniel-montalvo Feb 1, 2025
ba99c19
no caps
daniel-montalvo Feb 2, 2025
bb2cb83
Updates automation
daniel-montalvo Feb 2, 2025
e413577
Update workflow
daniel-montalvo Feb 2, 2025
74f2b88
Update git config email
daniel-montalvo Feb 2, 2025
7b718e5
Update git config email
daniel-montalvo Feb 2, 2025
7539f33
;
daniel-montalvo Feb 2, 2025
9d3aed7
Change auth
daniel-montalvo Feb 2, 2025
980f7aa
Update auth
daniel-montalvo Feb 2, 2025
050ed93
Update auth
daniel-montalvo Feb 2, 2025
43f47bc
Repo secrets
daniel-montalvo Feb 3, 2025
d13e6f8
Auth for gh cli
daniel-montalvo Feb 3, 2025
ee50ffc
Specify permissions
daniel-montalvo Feb 3, 2025
eff5804
Right reference to branch_name
daniel-montalvo Feb 3, 2025
d6d75ce
Org should be W3C
daniel-montalvo Feb 3, 2025
9fbecb0
Update .github/scripts/commons.mjs
daniel-montalvo Feb 3, 2025
31198f0
Remove assertion
daniel-montalvo Feb 3, 2025
ccef4c2
Try relying on const value
daniel-montalvo Feb 3, 2025
fbeb091
Define `nv` at a step level
daniel-montalvo Feb 3, 2025
da88433
Revert "Define `nv` at a step level"
daniel-montalvo Feb 4, 2025
39a0c3e
Tries pull_request_target
daniel-montalvo Feb 4, 2025
ba15ce0
Merge branch 'develop' into develop
daniel-montalvo Feb 7, 2025
9599ba6
Update .github/scripts/commons.mjs
daniel-montalvo Feb 7, 2025
342fa89
Revert "Tries pull_request_target"
daniel-montalvo Feb 7, 2025
5af9984
Add gh_repo setting
daniel-montalvo Feb 7, 2025
f78fcd8
workflow_dispatch
daniel-montalvo Feb 7, 2025
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
5 changes: 3 additions & 2 deletions .github/scripts/commons.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -18,8 +20,7 @@ export async function cloneWcagActRules({ tmpDir }) {
`;
}

export async function createOrCheckoutBranch({ tmpDir }, branchName) {
assert(branchName, 'branchName must be defined');
export async function createOrCheckoutBranch({ tmpDir }) {
cd(tmpDir);
try {
await $`git checkout ${branchName}`;
Expand Down
29 changes: 29 additions & 0 deletions .github/scripts/pr-preview.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env zx
import 'zx/globals';
import { config, cloneWcagActRules, createOrCheckoutBranch, commitAndPush, branchName } from './commons.mjs'

await cloneWcagActRules(config);
await createOrCheckoutBranch(config, branchName);
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 \
--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
`;
}
39 changes: 39 additions & 0 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PR Preview
on:
pull_request: {}
workflow_dispatch:

jobs:
dispatch:
runs-on: ubuntu-latest
permissions:
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
- 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-
- 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 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
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"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Loading