mirror of
https://github.com/GTNewHorizons/GTNH-Actions-Workflows.git
synced 2025-07-01 18:01:28 +02:00
Add upstream commentor script (#47)
This commit is contained in:
parent
32bd24ff1d
commit
bd16cd8b5c
48
.github/workflows/upstream_commentor.yml
vendored
Normal file
48
.github/workflows/upstream_commentor.yml
vendored
Normal file
@ -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'
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user