Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Don't trigger PR limit reminder on PRs that are ignored (#3596)

Madison Swain-Bowden0f2fdc363b17
diff --git a/.github/workflows/pr_limit_reminders.yml b/.github/workflows/pr_limit_reminders.yml
index e7178bd91..af4e70024 100644
--- a/.github/workflows/pr_limit_reminders.yml
+++ b/.github/workflows/pr_limit_reminders.yml
@@ -11,6 +11,7 @@ jobs:
outputs:
pr_count: ${{ steps.count-prs.outputs.pr_count }}
slack_id: ${{ steps.count-prs.outputs.slack_id }}
+ should_alert: ${{ steps.count-prs.outputs.should_alert }}
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v6
@@ -26,7 +27,7 @@ jobs:
send_message:
needs: analyze-user-prs
name: Send Slack message
- if: ${{ needs.analyze-user-prs.outputs.pr_count >= 3 }}
+ if: needs.analyze-user-prs.outputs.pr_count >= 3
runs-on: ubuntu-latest
env:
pr_count: ${{ needs.analyze-user-prs.outputs.pr_count }}
diff --git a/automations/js/src/count_user_reviewable_prs.js b/automations/js/src/count_user_reviewable_prs.js
index 90ea326cd..63d71e894 100644
--- a/automations/js/src/count_user_reviewable_prs.js
+++ b/automations/js/src/count_user_reviewable_prs.js
@@ -49,39 +49,46 @@ query ($repoOwner: String!, $repo: String!, $cursor: String) {
'🟥 priority: critical',
]
const [owner, repo] = GITHUB_REPOSITORY.split('/')
+ const isRelevantPrFromGraphql = (pr) =>
+ pr.author.login === context.actor &&
+ !pr.isDraft &&
+ !pr.labels.nodes.some((label) => ignoredLabels.includes(label.name))
+ const isRelevantPrFromContext = (pr) =>
+ !pr.draft && !pr.labels.some((label) => ignoredLabels.includes(label.name))
try {
let hasNextPage = true
let cursor = null
- let reviewablePRs = []
+ let reviewablePrs = []
+ const pullRequest = context.payload.pull_request
+ const result = {
+ pr_count: 0,
+ slack_id: slackID,
+ }
- while (hasNextPage) {
- const result = await github.graphql(GET_PULL_REQUESTS, {
- repoOwner: owner,
- repo: repo,
- cursor: cursor,
- })
+ // Check that this pull request is relevant, otherwise skip the action entirely
+ if (isRelevantPrFromContext(pullRequest)) {
+ while (hasNextPage) {
+ const result = await github.graphql(GET_PULL_REQUESTS, {
+ repoOwner: owner,
+ repo: repo,
+ cursor: cursor,
+ })
- const { nodes, pageInfo } = result.repository.pullRequests
- const validPRs = nodes.filter(
- (pr) =>
- pr.author.login === context.actor &&
- !pr.isDraft &&
- !pr.labels.nodes.some((label) => ignoredLabels.includes(label.name))
- )
- reviewablePRs.push(...validPRs)
+ const { nodes, pageInfo } = result.repository.pullRequests
+ const relevantPrs = nodes.filter(isRelevantPrFromGraphql)
+ reviewablePrs.push(...relevantPrs)
- if (pageInfo.hasNextPage) {
- cursor = pageInfo.endCursor
- } else {
- hasNextPage = false
+ if (pageInfo.hasNextPage) {
+ cursor = pageInfo.endCursor
+ } else {
+ hasNextPage = false
+ }
}
- }
- const result = {
- pr_count: reviewablePRs.length,
- slack_id: slackID,
+ result.pr_count = reviewablePrs.length
}
+
core.info(`Current user has ${result.pr_count} PR(s).`)
core.setOutput('pr_count', result.pr_count)
core.setOutput('slack_id', result.slack_id)