mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(gha): consolidate PR check comments into single report (#66869)
This commit is contained in:
committed by
GitHub
parent
6f059e8259
commit
88044e6990
@@ -51,7 +51,7 @@ jobs:
|
||||
}
|
||||
}
|
||||
core.setFailed("Invalid PR detected.");
|
||||
github.rest.issues.createComment({
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
name: GitHub - Lock Closed PRs
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [closed]
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
name: Lock Closed PR
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
await github.rest.issues.lock({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
lock_reason: 'resolved'
|
||||
});
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
}).catch(() => ({status: 404}));
|
||||
if (context.payload.pull_request.user.login !== "camperbot" && isDev.status !== 200) {
|
||||
core.setFailed('This PR appears to touch translated curriculum files.')
|
||||
github.rest.issues.createComment({
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
|
||||
@@ -104,25 +104,51 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: no-web-commits
|
||||
if: needs.no-web-commits.result == 'success'
|
||||
outputs:
|
||||
failure_reason: ${{ steps.check.outputs.failure_reason }}
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
sparse-checkout: .github/scripts/pr-guidelines
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
- id: check
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const fn = require('./.github/scripts/pr-guidelines/check-pr-template.js');
|
||||
await fn({ github, context, isAllowListed: '${{ needs.no-web-commits.outputs.is_allow_listed }}' });
|
||||
await fn({ github, context, core, isAllowListed: '${{ needs.no-web-commits.outputs.is_allow_listed }}' });
|
||||
|
||||
# Verifies that each PR references a linked, triaged issue before it can be reviewed.
|
||||
check-linked-issue:
|
||||
name: Check Linked Issue
|
||||
runs-on: ubuntu-24.04
|
||||
needs: no-web-commits
|
||||
if: needs.no-web-commits.result == 'success' && github.event.action != 'edited'
|
||||
if: needs.no-web-commits.result == 'success'
|
||||
outputs:
|
||||
failure_reason: ${{ steps.check.outputs.failure_reason }}
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
sparse-checkout: .github/scripts/pr-guidelines
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- id: check
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const fn = require('./.github/scripts/pr-guidelines/check-linked-issue.js');
|
||||
await fn({ github, context, core, isAllowListed: '${{ needs.no-web-commits.outputs.is_allow_listed }}' });
|
||||
|
||||
# Coordinates reporting: posts a single combined comment when checks fail,
|
||||
# or removes the deprioritized label when all checks pass.
|
||||
report:
|
||||
name: Report
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [no-web-commits, check-pr-template, check-linked-issue]
|
||||
if: always() && needs.no-web-commits.result == 'success'
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
@@ -133,5 +159,12 @@ jobs:
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const fn = require('./.github/scripts/pr-guidelines/check-linked-issue.js');
|
||||
await fn({ github, context, isAllowListed: '${{ needs.no-web-commits.outputs.is_allow_listed }}' });
|
||||
const fn = require('./.github/scripts/pr-guidelines/report-results.js');
|
||||
await fn({
|
||||
github,
|
||||
context,
|
||||
templateResult: '${{ needs.check-pr-template.result }}',
|
||||
templateReason: '${{ needs.check-pr-template.outputs.failure_reason }}',
|
||||
linkedIssueResult: '${{ needs.check-linked-issue.result }}',
|
||||
linkedIssueReason: '${{ needs.check-linked-issue.outputs.failure_reason }}'
|
||||
});
|
||||
|
||||
@@ -12,12 +12,15 @@ jobs:
|
||||
with:
|
||||
github-token: ${{secrets.CAMPERBOT_NO_TRANSLATE}}
|
||||
script: |
|
||||
const isSpam = context.payload.pull_request.labels.find(label => label.name === "spam");
|
||||
if (isSpam) {
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: "We are marking this pull request as spam. Please note that if you are participating in Hacktoberfest, two or more PRs marked as spam will result in your permanent disqualification.\n\nIf you are interested in making quality and genuine contributions to our projects, check out our [contributing guidelines](https://contribute.freecodecamp.org)."
|
||||
})
|
||||
if (context.payload.label.name === "spam") {
|
||||
try {
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: "We are marking this pull request as spam. Please note that if you are participating in Hacktoberfest, two or more PRs marked as spam will result in your permanent disqualification.\n\nIf you are interested in making quality and genuine contributions to our projects, check out our [contributing guidelines](https://contribute.freecodecamp.org)."
|
||||
});
|
||||
} catch {
|
||||
// Conversation may already be locked — ignore.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
with:
|
||||
github-token: ${{secrets.CAMPERBOT_NO_TRANSLATE}}
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
|
||||
Reference in New Issue
Block a user