Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fix pr-bot timing

shamoon0132c7bd6efe
diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml
index 69b98baef..1950f59b6 100644
--- a/.github/workflows/issue-bot.yml
+++ b/.github/workflows/issue-bot.yml
@@ -72,7 +72,7 @@ jobs:
'You are welcome to open a new issue that describes the problem you observed in your own words.'
: 'This issue was automatically closed because it was not opened using our bug report form. ' +
'Issues have to be created through the form so that the details we need to investigate are included.\n\n' +
- `If the problem is still there, please [open a new issue](${newIssue}) using the form. No other action is needed here.\n\n' +
+ `If the problem is still there, please [open a new issue](${newIssue}) using the form. No other action is needed here.\n\n` +
'If any part of your report was written by an AI tool or agent, you must say so: undisclosed AI-generated ' +
`contributions are a violation of our [Code of Conduct](${codeOfConduct}).`;
diff --git a/.github/workflows/pr-bot.yml b/.github/workflows/pr-bot.yml
index 6223c6db8..f7d69039d 100644
--- a/.github/workflows/pr-bot.yml
+++ b/.github/workflows/pr-bot.yml
@@ -25,6 +25,10 @@ jobs:
pr-bot:
name: Automated PR Bot
runs-on: ubuntu-latest
+ # Runs after Anti-slop so the welcome comment can see whether the PR was closed
+ # instead of racing it. Still runs if that job fails, so labeling is not lost.
+ needs: Anti-slop
+ if: ${{ !cancelled() }}
permissions:
contents: read
pull-requests: write
@@ -99,8 +103,25 @@ jobs:
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
- const pr = context.payload.pull_request;
- const user = pr.user.login;
+ const user = context.payload.pull_request.user.login;
+
+ // Re-read the PR: Anti-slop may have closed and labeled it after the webhook
+ const { data: pr } = await github.rest.pulls.get({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: context.payload.pull_request.number,
+ });
+
+ if (pr.state === 'closed') {
+ core.info('Skipping comment: PR is already closed');
+ return;
+ }
+
+ const labels = pr.labels.map((label) => (typeof label === 'string' ? label : label.name));
+ if (labels.includes('ai')) {
+ core.info('Skipping comment: PR is labeled ai');
+ return;
+ }
const { data: members } = await github.rest.orgs.listMembers({
org: 'paperless-ngx',