0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-12 05:37:26 +08:00
discourse/.github/workflows/backport.yml
Isaac Janzen 4120aec375
DEV: Allow patch triage bot to trigger backports (#40745)
### What
Allows `patch-triage[bot]` comments to satisfy the backport workflow
guard when it posts `@discoursebot backport`.

### Why
Patch triage needs to trigger the existing backport workflow, but bot
comments do not have one of the allowed human `author_association`
values.
2026-06-10 12:11:20 -05:00

56 lines
1.7 KiB
YAML
Vendored

name: Backport
on:
issue_comment:
types: [created]
jobs:
backport:
if: |
github.event.issue.pull_request &&
contains(github.event.comment.body, '@discoursebot backport') &&
(
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) ||
github.event.comment.user.login == 'patch-triage[bot]'
)
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
pull-requests: write
steps:
- name: Add reaction to comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
-f content='+1'
- name: Post start comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ github.event.issue.number }} \
--repo ${{ github.repository }} \
--body "Backport started. [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GH_PUSH_TOKEN }}
- name: Configure Git
run: |
git config --global user.name "Discourse CI"
git config --global user.email "ci@ci.invalid"
- name: Perform backport
env:
GH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
COMMENT_BODY: ${{ github.event.comment.body }}
run: ruby script/backport.rb