Implement javascript handlers for UI interactions #22
This file contains 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
on: | |
issue_comment: | |
types: | |
- created | |
pull_request_target: | |
types: | |
- auto_merge_enabled | |
env: | |
AUTO_REBASE_PERSONAL_ACCESS_TOKEN: | |
${{ secrets.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }} | |
jobs: | |
check-token: | |
if: | | |
( | |
github.event.issue.pull_request && | |
contains(github.event.comment.body, '/rebase') | |
) || | |
github.event_name == 'pull_request_target' | |
runs-on: ubuntu-latest | |
steps: | |
- if: "! env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN" | |
name: Prompt to add a token | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ github.event.issue.number || github.event.number }} | |
body: | | |
To automatically rebase, you need to add a [personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with the name `AUTO_REBASE_PERSONAL_ACCESS_TOKEN` to the [secrets section of this repo](https://github.com/${{ github.event.repository.full_name }}/settings/secrets/actions). | |
Once this is done, you can try the `/rebase` command again. | |
- if: github.event.comment | |
name: React to the triggering comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
reactions: | |
${{ env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN && '+1' || '-1' }} | |
- if: "! env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN" | |
name: Return a failing state if we have no token | |
run: exit 1 | |
rebase: | |
needs: check-token | |
name: Rebase | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }} | |
fetch-depth: 0 | |
- name: Rebase on top of the default branch | |
uses: cirrus-actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }} | |
- if: failure() | |
name: Notify of the failure | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ github.event.issue.number || github.event.number }} | |
body: | | |
Automatic rebasing for this issue has failed :disappointed: | |
You'll have to rebase this one manually, I'm afraid. | |
- if: success() && github.event.comment | |
name: React to the triggering comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
reactions: hooray |