mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 09:47:56 -05:00
ci: fix false first-PR welcome for issue-less repeat contributors (#3502)
actions/first-interaction@v3.1.0's isFirstPullRequest() never filters by author, and the action only skips the greeting when neither isFirstIssue nor isFirstPullRequest is true. A contributor who has never filed an issue trips a vacuously-true isFirstIssue, which alone opens the gate regardless of their real PR history. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
2104b33ea7
commit
341736fc39
1 file changed
+58
-12
@@ -13,9 +13,34 @@ permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
# actions/first-interaction@v3.1.0's isFirstPullRequest() has no author filter
|
||||
# (pulls.list has no creator parameter, and the action applies none itself:
|
||||
# https://github.com/actions/first-interaction/pull/402), and its top-level gate
|
||||
# greets on ANY first contribution, issue or PR: a sender who has merged dozens of
|
||||
# PRs but never opened an issue still trips a vacuously-true isFirstIssue and gets
|
||||
# welcomed as a first-time PR author. Both upstream fixes (actions/first-interaction#402
|
||||
# and actions/first-interaction#410) are open and unreleased, so the PR side below
|
||||
# bypasses the action and checks authorship itself
|
||||
# via the Search API; the issue side is unaffected (isFirstIssue does filter by
|
||||
# creator) and keeps using the action.
|
||||
PR_MESSAGE: |
|
||||
🎉 Thanks for your first pull request to Floci!
|
||||
|
||||
**Your CI checks need a maintainer to approve them before they run.** That is GitHub's standard gate on first-time contributors, not a problem with your PR — so if the checks look like they are doing nothing, that is why. Once a maintainer approves, CI and the compatibility suite start automatically. Nothing is needed from you in the meantime.
|
||||
|
||||
While you wait, a couple of things that make review faster:
|
||||
|
||||
- Link the issue this fixes with `Closes #N` in the description
|
||||
- Commits follow [Conventional Commits](https://www.conventionalcommits.org/) (`feat(s3): ...`, `fix(dynamodb): ...`)
|
||||
- Behaviour changes come with a test — see [CONTRIBUTING.md](https://github.com/floci-io/floci/blob/main/CONTRIBUTING.md)
|
||||
|
||||
Come join us in [Slack](https://join.slack.com/t/floci/shared_invite/zt-3tjn02s3q-A00kEjJ1cZxsg_imTfy6Cw) — it is the fastest way to reach maintainers if you get stuck, or want feedback on an approach before investing more time in it.
|
||||
|
||||
jobs:
|
||||
welcome:
|
||||
name: Greet on first issue or PR
|
||||
welcome-issue:
|
||||
name: Greet on first issue
|
||||
if: github.event_name == 'issues'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -33,15 +58,36 @@ jobs:
|
||||
|
||||
Come say hi in [Slack](https://join.slack.com/t/floci/shared_invite/zt-3tjn02s3q-A00kEjJ1cZxsg_imTfy6Cw) if you want to talk it through with maintainers and other contributors. Questions about AWS behaviour, design tradeoffs, and rough proposals are all welcome there.
|
||||
|
||||
pr_message: |
|
||||
🎉 Thanks for your first pull request to Floci!
|
||||
# Unused on this event (isIssue is always true here), but the action reads
|
||||
# this input unconditionally and fails if it is missing.
|
||||
pr_message: ${{ env.PR_MESSAGE }}
|
||||
|
||||
**Your CI checks need a maintainer to approve them before they run.** That is GitHub's standard gate on first-time contributors, not a problem with your PR — so if the checks look like they are doing nothing, that is why. Once a maintainer approves, CI and the compatibility suite start automatically. Nothing is needed from you in the meantime.
|
||||
welcome-pr:
|
||||
name: Greet on first PR
|
||||
if: github.event_name == 'pull_request_target'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
While you wait, a couple of things that make review faster:
|
||||
|
||||
- Link the issue this fixes with `Closes #N` in the description
|
||||
- Commits follow [Conventional Commits](https://www.conventionalcommits.org/) (`feat(s3): ...`, `fix(dynamodb): ...`)
|
||||
- Behaviour changes come with a test — see [CONTRIBUTING.md](https://github.com/floci-io/floci/blob/main/CONTRIBUTING.md)
|
||||
|
||||
Come join us in [Slack](https://join.slack.com/t/floci/shared_invite/zt-3tjn02s3q-A00kEjJ1cZxsg_imTfy6Cw) — it is the fastest way to reach maintainers if you get stuck, or want feedback on an approach before investing more time in it.
|
||||
steps:
|
||||
# Checking total_count alone cannot tell "genuine first PR, not indexed yet"
|
||||
# apart from "repeat contributor, only their prior PR is indexed": both read
|
||||
# as total_count <= 1 while the just-opened PR is not indexed yet. Instead,
|
||||
# look at the returned items and skip only if one of them is NOT this PR.
|
||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const { data } = await github.rest.search.issuesAndPullRequests({
|
||||
q: `repo:${context.repo.owner}/${context.repo.repo} type:pr author:${context.payload.sender.login}`,
|
||||
per_page: 2
|
||||
})
|
||||
const hasPriorPr = data.items.some(item => item.number !== context.issue.number)
|
||||
if (hasPriorPr) {
|
||||
core.info('Skipping...Not First Contribution')
|
||||
return
|
||||
}
|
||||
core.info(`Adding Message to #${context.issue.number}`)
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: process.env.PR_MESSAGE
|
||||
})
|
||||
Reference in new issue
Block a user