Docs/applications guide #28
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: CI Build | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| statuses: write | |
| jobs: | |
| build: | |
| name: CI Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Signal admin-may-merge for non-docs PRs | |
| if: success() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const files = await github.paginate(github.rest.pulls.listFiles, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: prNumber, | |
| per_page: 100, | |
| }); | |
| const touchesDocs = files.some(f => f.filename.startsWith('docs/')); | |
| if (touchesDocs) return; // docs PRs are handled by stage-progression.yml | |
| // Flip the review-workflow commit status to success so branch | |
| // protection allows merge. This is the non-docs counterpart to | |
| // stage-progression.yml's status-setting for docs PRs. | |
| const headSha = context.payload.pull_request.head.sha; | |
| await github.rest.repos.createCommitStatus({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| sha: headSha, | |
| state: 'success', | |
| context: 'review-workflow', | |
| description: 'No doc changes — admin may merge', | |
| }); | |
| const marker = '<!-- ci-admin-merge-bot-comment -->'; | |
| const sha = headSha.substring(0, 7); | |
| const body = `${marker}\n\n✅ **CI build passed** for commit \`${sha}\`\n\nThis PR does not touch documentation content under \`docs/\`, so no multi-stage review is required.\n\n@usace-rmc/docs-admin may merge.`; | |
| const comments = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber }); | |
| const existing = comments.data.find(c => c.user.type === 'Bot' && c.body.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: existing.id, body }); | |
| } else { | |
| await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, body }); | |
| } |