-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (50 loc) · 1.84 KB
/
rebase-default-branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# GitHub Actions Virtual Environments
# https://github.com/actions/virtual-environments/
# Rebases a pull request on the repo's default branch when the "rebase" label is added
# Note: you'll need to add a personal access token to your repo, `PERSONAL_ACCESS_TOKEN`. (`REBASE_PR_TOKEN`)
# Link: https://github.com/jessesquires/gh-workflows/blob/main/.github/workflows/rebase-default-branch.yml
name: Rebase Pull Request
on:
pull_request:
types: [ labeled ]
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
jobs:
main:
if: ${{ contains(github.event.*.labels.*.name, 'rebase') }}
name: Rebase
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
# Link: https://httgp.com/signing-commits-in-github-actions/
- name: Import bot's GPG key for signing commits
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: perform rebase
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git status
git pull
git checkout "$DEFAULT_BRANCH"
git status
git pull
git checkout "$GITHUB_HEAD_REF"
git rebase "$DEFAULT_BRANCH"
git push --force-with-lease
git status
# Link: https://github.com/marketplace/actions/actions-ecosystem-remove-labels
- name: remove label
if: always()
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: rebase