mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
CI: skip draft-pr-policy checkout on issue-only comments (#6519)
* ci: skip draft-pr-policy checkout on issue-only comments The issue_comment event fires for comments on both issues and PRs; draft-pr-policy only cares about PR draft-staleness, so short-circuit before checkout when the comment is on a plain issue. Also switch all three jobs to a sparse, shallow checkout since they only need .github/scripts to load the github-script payload. * ci: also skip draft-pr-policy on bot-authored PR comments draft-pr-policy.js already excludes Bot comments when deciding whether a draft was revived, so a bot comment (e.g. review-checklist posting its checklist) can never do anything meaningful here — it still ran checkout + API calls only to no-op. Filter it out at the same if: using the free github.event.comment.user.type field. * ci: skip checkout for draft-pr-policy on non-draft PR comments Even after filtering out issue-only and bot comments, a human comment on any non-draft PR still paid for a full checkout just to have the script itself discover pr.draft is false and return. Add a cheap pulls.get-only pre-check step (no checkout required) and gate the real checkout + script load on its result.
This commit is contained in:
@@ -30,6 +30,8 @@ jobs:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
sparse-checkout: .github/scripts
|
||||
fetch-depth: 1
|
||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
@@ -37,17 +39,39 @@ jobs:
|
||||
await runMarkStale({ github, context, core });
|
||||
|
||||
draft-pr-policy:
|
||||
if: github.repository_owner == 'HDFGroup'
|
||||
if: >-
|
||||
github.repository_owner == 'HDFGroup' &&
|
||||
(github.event_name != 'issue_comment' ||
|
||||
(github.event.issue.pull_request != null && github.event.comment.user.type != 'Bot'))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
# No checkout needed here — just an API call to see if this comment's
|
||||
# PR is even a draft, before paying for checkout + loading the script.
|
||||
- name: Check draft status
|
||||
id: check
|
||||
if: github.event_name == 'issue_comment'
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const { data: pr } = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.payload.issue.number,
|
||||
});
|
||||
core.setOutput('is_draft', pr.draft ? 'true' : 'false');
|
||||
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
if: steps.check.outputs.is_draft != 'false'
|
||||
with:
|
||||
persist-credentials: false
|
||||
sparse-checkout: .github/scripts
|
||||
fetch-depth: 1
|
||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
if: steps.check.outputs.is_draft != 'false'
|
||||
with:
|
||||
script: |
|
||||
const { runDraftPolicy } = require('${{ github.workspace }}/.github/scripts/draft-pr-policy.js');
|
||||
@@ -65,6 +89,8 @@ jobs:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
sparse-checkout: .github/scripts
|
||||
fetch-depth: 1
|
||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
|
||||
Reference in New Issue
Block a user