From bd16cd8b5c6af23493870e23dc046b6173b7e832 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Thu, 8 May 2025 00:16:20 -0500 Subject: [PATCH] Add upstream commentor script (#47) --- .github/workflows/upstream_commentor.yml | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/upstream_commentor.yml diff --git a/.github/workflows/upstream_commentor.yml b/.github/workflows/upstream_commentor.yml new file mode 100644 index 0000000..2008917 --- /dev/null +++ b/.github/workflows/upstream_commentor.yml @@ -0,0 +1,48 @@ +name: Mention upstream repo for new pull requests + +on: + workflow_call: + inputs: + upstream: + description: 'URL to the upstream repository' + required: true + type: string + auto_close: + description: 'Whether to close the PR after commenting' + required: false + default: false + type: boolean + +jobs: + comment: + runs-on: ubuntu-latest + + steps: + - name: Comment on PR + uses: actions/github-script@v7 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + upstream: ${{ inputs.upstream }} + auto_close: ${{ inputs.auto_close }} + script: | + const upstream = core.getInput('upstream'); + const commentBody = `Thanks for the PR! + + PRs to this repo should be closed and reopened on the [upstream repo](${upstream}) instead of the GTNH fork. This can be ignored if there is a good reason to PR to specifically the fork instead.`; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: commentBody + }); + + const auto_close = core.getBooleanInput('auto_close'); + if (auto_close) { + github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed' + }); + }