Skip to content

Commit

Permalink
Direct Netlify setup for PR preview deploys (#2307)
Browse files Browse the repository at this point in the history
* Direct Netlify setup for PR preview deploys

* Update netlify.toml
  • Loading branch information
daniel-montalvo authored Feb 13, 2025
1 parent 8d979ef commit 7c50fae
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/scripts/pr-preview.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env zx
import 'zx/globals';
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 \
--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
`;
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ yarn.lock

# Tmp build directory
wcag-act-rules-tmp/

# Local Netlify folder
.netlify
15 changes: 15 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[build]
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'"
# base = "wcag-act-rules-tmp"
publish = "wcag-act-rules-tmp/_site"

[build.environment]
RUBY_VERSION = "3.3.3"

[[redirects]]
from = "/"
to = "/standards-guidelines/act/rules/"

[[redirects]]
from = "/standards-guidelines/act/rules/*"
to = "/standards-guidelines/at/rules/:splat/proposed"
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

0 comments on commit 7c50fae

Please sign in to comment.