-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add a Rebase Branch workflow to rebase staging on top of ma…
…in after a package was published (#536)
- Loading branch information
1 parent
8be21a5
commit 7d9f0a4
Showing
3 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Automatically rebase one branch on top of another; usually staging on top | ||
# of main after a new package version was published. | ||
|
||
name: Rebase branch | ||
on: | ||
workflow_call: | ||
inputs: | ||
to_head: | ||
type: string | ||
required: true | ||
description: Branch that is being rebased | ||
from_base: | ||
type: string | ||
required: true | ||
description: Base branch | ||
git_user_name: | ||
required: true | ||
type: string | ||
description: Name of the git user that rebases and pushes the to_head branch | ||
git_user_email: | ||
required: true | ||
type: string | ||
description: Email address of said git user | ||
secrets: | ||
REPO_ACCESS_TOKEN: | ||
required: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
rebase: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Harden Runner | ||
uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1 | ||
with: | ||
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | ||
|
||
- name: Check out repository | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
ref: ${{ github.ref_name }} | ||
|
||
- name: Do rebase | ||
run: | | ||
git config --global user.name "$USER_NAME" | ||
git config --global user.email "$USER_EMAIL" | ||
git checkout "$TO_HEAD" | ||
git rebase "$FROM_BASE" | ||
git push --force-with-lease | ||
env: | ||
USER_NAME: ${{ inputs.git_user_name }} | ||
USER_EMAIL: ${{ inputs.git_user_email }} | ||
TO_HEAD: ${{ inputs.to_head }} | ||
FROM_BASE: ${{ inputs.from_base }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,3 +251,21 @@ jobs: | |
git_user_email: [email protected] | ||
secrets: | ||
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
|
||
# After the bump commit was pushed to the main branch, rebase the staging branch | ||
# (to_head argument) on top of the new main branch (from_base argument), to keep | ||
# the histories of both branches in sync. | ||
rebase_staging: | ||
# if: ${{ false }} | ||
needs: [release] | ||
name: Rebase staging branch on main | ||
uses: ./.github/workflows/_generate-rebase.yaml | ||
permissions: | ||
contents: read | ||
with: | ||
to_head: staging | ||
from_base: origin/main | ||
git_user_name: jenstroeger | ||
git_user_email: [email protected] | ||
secrets: | ||
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} |
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