Replace broken actions/first-interaction with an inline github-script - #398
Open
tpvasconcelos wants to merge 4 commits into
Open
Replace broken actions/first-interaction with an inline github-script#398tpvasconcelos wants to merge 4 commits into
actions/first-interaction with an inline github-script#398tpvasconcelos wants to merge 4 commits into
Conversation
The v3 rewrite of actions/first-interaction dropped the per-author filter from its first-PR check and ORs the issue/PR checks together, so the "first pull request" greeting fires for every PR whose author has never opened an issue in this repo - i.e. on every single PR from pre-commit.ci, dependabot, and Copilot. Broken upstream since v3.1.0 with no fix available (actions/first-interaction#369). Replace it with an inline actions/github-script step that restores the correct v1 semantics, never greets bots, runs with a least-privilege token, and fails soft on API errors.
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #398 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 19 19
Lines 674 674
Branches 88 88
=========================================
Hits 674 674
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Move the inline github-script logic into a composite action under .github/actions/greet-new-users/ with the core logic in a standalone, directly-testable main.js module. This makes the action consumable from other repositories and easy to open source later by moving the directory to a standalone repository. The action exposes issue-message/pr-message/token inputs and a greeted output, and gains two reusability guards: it only acts on 'opened' events (preventing duplicate greetings if a consumer also triggers on 'edited') and it skips unsupported events gracefully. The workflow now checks out the base ref (never the PR head) to load the local action.
Use issue_message/pr_message (snake_case) for the action's inputs, consistent with the actions/first-interaction action being replaced.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
actions/first-interaction@v3posts the "first pull request" greeting on every PR from any author who has never opened an issue in this repo — which in practice means every PR from pre-commit.ci, dependabot, and Copilot (#350, #355, #358, #362, #366, #374, #379, #380–#383, #395, ...). The v3 rewrite introduced two regressions: it ORs the first-issue/first-PR checks together instead of branching on the event type, and its first-PR check lost the per-author filter entirely. The bug also affects humans: any contributor who never filed an issue here would be re-greeted on every new PR. Upstream has been broken since Oct 2025 with no fix in sight.This PR replaces the action with a local reusable composite action,
.github/actions/greet-new-users, built onactions/github-script@v9(already a dependency of other workflows here) with the core logic in a standalone, directly-testablemain.jsmodule. It restores the correct v1 semantics and hardens the workflow:user.type == "Bot": pre-commit.ci, dependabot, github-actions, Copilot, ...)OWNER/MEMBER/COLLABORATORauthors cheaply (shortcut only — a missing/unreliableauthor_associationfalls through to the real check, so it can never cause a wrong greeting)permissions:block (contents: read+issues: write+pull-requests: write) instead of the repo-default write-all tokenpull_request_targetworkflow only ever checks out the base ref (required to load the local action; PR authors cannot alter the code this privileged workflow runs), and no untrusted fields are${{ }}-interpolated into script source (messages flow throughenv, payload fields are read viacontext.payload)The action is reusable by design —
issue_message/pr_message/tokeninputs, agreetedoutput, only acts onopenedevents (no duplicate greetings if a consumer also triggers onedited), and skips unsupported events gracefully — so other repos can consume it viauses: tpvasconcelos/ridgeplot/.github/actions/greet-new-users@main, and open-sourcing it later is just a matter of moving the directory to a standalone repository.Validation performed:
check-yaml, GitHub Actions/workflow schema validation,actionlint, and thetimeout-minuteshook)main.jswas behavior-tested under Node against mockedcore/context/githubobjects replaying real scenarios: pre-commit-ci's [pre-commit.ci] pre-commit autoupdate #395, owner PRs, a repeat external contributor, a genuine first PR/issue, a second issue from the same reporter, a first issue from a previous PR author, an API failure, aneditedevent, an unsupported event, and an empty message — 11/11 passNote:
issuesandpull_request_targetworkflows run the default-branch version, so this only takes effect after merging. The next pre-commit.ci autoupdate is the natural negative test; the next external contributor is the positive one.Related issues
Upstream: actions/first-interaction#369 (broken first-contribution detection), actions/first-interaction#394 (request to ignore bots). Latest upstream release is still v3.1.0 (Oct 2025); both issues remain open.
PR check list
main.jswas behavior-tested under Node with mocked payloads — see description.)docs/reference/changelog.md.📚 Documentation preview 📚: https://ridgeplot--398.org.readthedocs.build/en/398/