ci: improve PR docs publishing #12457
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pull Request Checks | |
| on: [pull_request, merge_group] | |
| concurrency: | |
| # Only allow one active run of this workflow, per PR. | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/set-up-node | |
| - run: npm ci | |
| - run: npm run lint | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/set-up-node | |
| - run: npm ci | |
| - name: Ensure installed React and React-DOM versions match | |
| run: | | |
| REACT_VERSION=$(npm ls react --depth=0 --json | jq -r '.dependencies.react.version') | |
| REACT_DOM_VERSION=$(npm ls react-dom --depth=0 --json | jq -r '.dependencies["react-dom"].version') | |
| echo "Installed React: $REACT_VERSION" | |
| echo "Installed React-DOM: $REACT_DOM_VERSION" | |
| if [ "$REACT_VERSION" != "$REACT_DOM_VERSION" ]; then | |
| echo "ERROR: Installed React and React-DOM versions must match!" | |
| exit 1 | |
| fi | |
| - run: npm run build | |
| - run: npm run build # Needed to avoid incremental build quirks | |
| - run: npm run api:verify | |
| test: | |
| name: Test | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/set-up-node | |
| - run: npm ci | |
| - run: npm test --if-present | |
| commitlint: | |
| name: Commitlint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: github.actor != 'dependabot[bot]' && github.event_name != 'merge_group' | |
| - uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1 | |
| if: github.actor != 'dependabot[bot]' && github.event_name != 'merge_group' | |
| autosquash: | |
| name: Block Autosquash Commits | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Block Autosquash Commits | |
| if: github.event_name != 'merge_group' | |
| uses: xt0rted/block-autosquash-commits-action@79880c36b4811fe549cfffe20233df88876024e7 # v2.2.0 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| docs: | |
| name: Docs | |
| if: github.event_name != 'merge_group' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| uses: ./.github/workflows/build-docs.yml | |
| with: | |
| version: "PR-${{ github.event.pull_request.number }}" | |
| prNumber: ${{ github.event.pull_request.number }} | |
| # For same-repo PRs, publish directly. For fork PRs, build only (publishing handled by publish-pr-docs workflow). | |
| buildOnly: ${{ github.event.pull_request.head.repo.fork }} | |
| secrets: inherit | |
| automerge: | |
| needs: [lint, build, test, autosquash, docs] | |
| if: github.event.pull_request.head.repo.owner.login == 'Lundalogik' && github.actor == 'dependabot[bot]' && github.event_name != 'merge_group' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Automerge | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| MERGE_TOKEN: ${{ secrets.MERGE_AUTOMATIC_PR }} | |
| run: | | |
| curl -L -X PUT \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $MERGE_TOKEN" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/Lundalogik/lime-elements/pulls/$PR_NUMBER/merge \ | |
| -d '{"merge_method":"rebase"}' |