Skip to content

Commit 7c50fae

Browse files
Direct Netlify setup for PR preview deploys (#2307)
* Direct Netlify setup for PR preview deploys * Update netlify.toml
1 parent 8d979ef commit 7c50fae

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

.github/scripts/pr-preview.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env zx
2+
import 'zx/globals';
3+
import { config, cloneWcagActRules, commitAndPush } from './commons.mjs'
4+
5+
await cloneWcagActRules(config);
6+
await generateProposedRulePages(config);
7+
await generateTestCases(config);
8+
// const commitMessage = (await $`git log -1 --pretty=%B`).stdout;
9+
// await commitAndPush(config, commitMessage);
10+
11+
async function generateProposedRulePages({ tmpDir, rulesDir, glossaryDir, testAssetsDir }) {
12+
await $`node ./node_modules/act-tools/dist/cli/rule-transform.js \
13+
--rulesDir "${rulesDir}" \
14+
--glossaryDir "${glossaryDir}" \
15+
--testAssetsDir "${testAssetsDir}" \
16+
--outDir "${tmpDir}" \
17+
--proposed
18+
`;
19+
}
20+
21+
async function generateTestCases({ tmpDir, rulesDir, testAssetsDir }) {
22+
await $`node ./node_modules/act-tools/dist/cli/build-examples.js \
23+
--rulesDir "${rulesDir}" \
24+
--testAssetsDir "${testAssetsDir}" \
25+
--outDir "${tmpDir}" \
26+
--proposed
27+
`;
28+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ yarn.lock
7272

7373
# Tmp build directory
7474
wcag-act-rules-tmp/
75+
76+
# Local Netlify folder
77+
.netlify

netlify.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[build]
2+
command = "npm run pr:preview && cd wcag-act-rules-tmp && git submodule update --init --remote && bundle install && bundle exec jekyll build --config '_config.yml,_config_staging.yml'"
3+
# base = "wcag-act-rules-tmp"
4+
publish = "wcag-act-rules-tmp/_site"
5+
6+
[build.environment]
7+
RUBY_VERSION = "3.3.3"
8+
9+
[[redirects]]
10+
from = "/"
11+
to = "/standards-guidelines/act/rules/"
12+
13+
[[redirects]]
14+
from = "/standards-guidelines/act/rules/*"
15+
to = "/standards-guidelines/at/rules/:splat/proposed"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@
177177
"formatRulesDir": "prettier --write './_rules/**/*.md'",
178178
"format": "prettier --write *.{json,md,js,html,css,yml} './{__tests__,_rules,.github,pages,test-assets,test-utils,utils}/**/*.{json,md,js,html,css,yml}'",
179179
"test": "jest --coverage",
180-
"build:wai": "zx .github/scripts/wai-build.mjs"
180+
"build:wai": "zx .github/scripts/wai-build.mjs",
181+
"pr:preview": "zx .github/scripts/pr-preview.mjs"
181182
},
182183
"homepage": "https://github.com/act-rules/act-rules.github.io",
183184
"repository": {

0 commit comments

Comments
 (0)