Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions common/.github/workflows/rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Automatic Rebase
on:
pull_request:
types: [labeled]

permissions:
contents: read

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rebasing would also need write perms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it does, but we end up using the app token for this which bypasses this.

That said, it's probably safer to use GITHUB_TOKEN? From the docs on https://github.com/peter-evans/rebase it looks like it might work

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, let's go for it then:)


jobs:
rebase:
name: Rebase
if: github.event.label.name == 'needs-rebase'
runs-on: ubuntu-latest
steps:
- name: Generate Actions Token
id: token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}

- name: Checkout
uses: actions/checkout@v5
with:
token: ${{ steps.token.outputs.token }}
fetch-depth: 0

- name: Automatic Rebase
uses: peter-evans/rebase@v3
with:
token: ${{ steps.token.outputs.token }}

- name: Remove needs-rebase label
if: always()
uses: actions/github-script@v8
with:
github-token: ${{ steps.token.outputs.token }}
script: |
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'needs-rebase'
});