diff --git a/.github/workflows/publish-generated-docs.yml b/.github/workflows/publish-generated-docs.yml new file mode 100644 index 0000000000..9fa7c68eaf --- /dev/null +++ b/.github/workflows/publish-generated-docs.yml @@ -0,0 +1,67 @@ +name: Publish generated docs + +on: + push: + branches: + - generated-docs # TODO: switch to develop + +env: + BRANCH_NAME: publish-generated-docs + +jobs: + generate_docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Generate docs files + run: | + npm ci + npm run build -- --all-lang + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: generated-docs + path: tmp/doc + + push_to_axe_site_repo: + needs: generate_docs + runs-on: ubuntu-latest + steps: + - name: Checkout axe site repository + uses: actions/checkout@v4 + with: + repository: ${{ secrets.AXE_SITE_REPO }} + token: ${{ secrets.AXE_SITE_REPO_TOKEN }} + fetch-depth: 0 + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: generated-docs + path: ../generated-docs + + - name: Copy docs files to target branch + run: | + git status + git config user.name github-actions + git config user.email github-actions@github.com + git checkout $BRANCH_NAME || git checkout -b $BRANCH_NAME + cp -r ../generated-docs/* src/pages/docs/markdown/ + + - name: Check for changes + id: changes + run: | + changes=$(git status --porcelain) + # see https://unix.stackexchange.com/a/509498 + echo $changes | grep . && echo "Changes detected" || echo "No changes" + echo "changes=$changes" >> "$GITHUB_OUTPUT" + + - name: Push branch to axe site repository + if: steps.changes.outputs.changes != '' + run: | + git add . + git commit -m "chore(docs): publish generated docs" + git push origin $BRANCH_NAME diff --git a/.gitignore b/.gitignore index fe79e6d264..c5acaafba1 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,3 @@ doc/api/* # ts generated file typings/axe-core/axe-core-tests.js - -# doc -doc/rule-descriptions.*.md - diff --git a/Gruntfile.js b/Gruntfile.js index 64cfb9ab1d..2e387843e8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -129,7 +129,7 @@ module.exports = function (grunt) { 'aria-supported': { data: { entry: 'lib/commons/aria/index.js', - destFile: 'doc/aria-supported.md', + destFile: 'tmp/doc/aria-supported.md', options: { langs: langs }, @@ -147,7 +147,7 @@ module.exports = function (grunt) { src: [''], dest: { auto: 'tmp/rules' + lang + '.js', - descriptions: 'doc/rule-descriptions' + lang + '.md' + descriptions: 'tmp/doc/rule-descriptions' + lang + '.md' } }; }) diff --git a/package.json b/package.json index 7c99fba10a..c740f54faf 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ ], "standard-version": { "scripts": { - "postbump": "npm ci && npm run sri-update && git add doc/rule-descriptions.md" + "postbump": "npm ci && npm run sri-update" }, "skip": { "tag": true @@ -113,7 +113,7 @@ "prepare": "husky", "prebuild": "node ./build/check-node-version.js", "pretest": "node ./build/check-node-version.js", - "postbuild": "prettier --write ./locales/_template.json ./doc/rule-descriptions.md" + "postbuild": "prettier --write ./locales/_template.json" }, "devDependencies": { "@axe-core/webdriverjs": "^4.9.0",