|
| 1 | +name: Documentation Quality Check |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main, docs-ng] |
| 6 | + types: [opened, synchronize, reopened, closed] |
| 7 | + paths: |
| 8 | + - 'docs/**' |
| 9 | + push: |
| 10 | + branches: [main, docs-ng] |
| 11 | + paths: |
| 12 | + - 'docs/**' |
| 13 | + |
| 14 | +jobs: |
| 15 | + docs-checks: |
| 16 | + # Skip checks on closed PRs (only need the notification) |
| 17 | + if: github.event_name != 'pull_request' || github.event.action != 'closed' |
| 18 | + uses: gardenlinux/docs-ng/.github/workflows/docs-checks.yml@main |
| 19 | + with: |
| 20 | + override-repo: ${{ github.event.repository.name }} |
| 21 | + override-ref: ${{ github.head_ref || github.ref_name }} |
| 22 | + override-commit: ${{ github.event.pull_request.head.sha || github.sha }} |
| 23 | + |
| 24 | + notify-docs-ng: |
| 25 | + name: Notify docs-ng |
| 26 | + needs: [docs-checks] |
| 27 | + runs-on: ubuntu-24.04 |
| 28 | + # Only notify for PR events (not push events which lack PR context) |
| 29 | + # Run after checks pass for open PRs, OR immediately for merged PRs |
| 30 | + if: | |
| 31 | + always() && |
| 32 | + github.event_name == 'pull_request' && |
| 33 | + ( |
| 34 | + (github.event.action == 'closed' && github.event.pull_request.merged == true) || |
| 35 | + (github.event.action != 'closed' && needs.docs-checks.result == 'success') |
| 36 | + ) |
| 37 | + steps: |
| 38 | + - name: Generate GitHub App token |
| 39 | + id: app-token |
| 40 | + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 |
| 41 | + with: |
| 42 | + app-id: ${{ secrets.DOCS_BOT_APP_ID }} |
| 43 | + private-key: ${{ secrets.DOCS_BOT_PRIVATE_KEY }} |
| 44 | + repositories: docs-ng |
| 45 | + |
| 46 | + - name: Send repository dispatch to docs-ng |
| 47 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 48 | + with: |
| 49 | + github-token: ${{ steps.app-token.outputs.token }} |
| 50 | + script: | |
| 51 | + const isMergedPR = context.payload.action === 'closed' && |
| 52 | + context.payload.pull_request.merged === true; |
| 53 | +
|
| 54 | + // For merged PRs, use the base branch (the branch it was merged into) |
| 55 | + // For open PRs, use the head branch (feature branch) |
| 56 | + const ref = isMergedPR |
| 57 | + ? context.payload.pull_request.base.ref |
| 58 | + : context.payload.pull_request.head.ref; |
| 59 | +
|
| 60 | + await github.rest.repos.createDispatchEvent({ |
| 61 | + owner: 'gardenlinux', |
| 62 | + repo: 'docs-ng', |
| 63 | + event_type: 'docs-pr', |
| 64 | + client_payload: { |
| 65 | + repo: '${{ github.event.repository.name }}', |
| 66 | + pr_number: `${context.payload.pull_request.number}`, |
| 67 | + commit_sha: isMergedPR |
| 68 | + ? context.payload.pull_request.merge_commit_sha |
| 69 | + : context.payload.pull_request.head.sha, |
| 70 | + ref: ref, |
| 71 | + event: isMergedPR ? 'merged' : 'pr_success' |
| 72 | + } |
| 73 | + }); |
| 74 | + core.info('Repository dispatch sent to docs-ng'); |
0 commit comments