forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix sync-rc.yml (autowarefoundation#402)
Signed-off-by: Kenji Miyake <[email protected]>
- Loading branch information
1 parent
dcd9a57
commit 4b4db9e
Showing
1 changed file
with
29 additions
and
4 deletions.
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 |
---|---|---|
|
@@ -7,10 +7,13 @@ on: | |
types: | ||
- closed | ||
workflow_dispatch: | ||
inputs: | ||
rc_branch: | ||
description: "Target RC branch(e.g. rc/v1.0.0)" | ||
required: true | ||
|
||
env: | ||
BASE_BRANCH: main | ||
SYNC_BRANCH: sync-rc | ||
|
||
jobs: | ||
sync-rc: | ||
|
@@ -30,15 +33,37 @@ jobs: | |
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: Set SYNC_TARGET_BRANCH | ||
- name: Set SYNC_TARGET_BRANCH for pull_request event | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
echo "SYNC_TARGET_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV | ||
echo "SYNC_TARGET_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV | ||
- name: Set SYNC_TARGET_BRANCH for workflow_dispatch event | ||
if: github.event_name == 'workflow_dispatch' | ||
run: | | ||
echo "SYNC_TARGET_BRANCH=${{ github.event.inputs.rc_branch }}" >> $GITHUB_ENV | ||
- name: Set SYNC_BRANCH | ||
run: | | ||
echo ${SYNC_TARGET_BRANCH} | grep -e "^rc/v.*" | ||
echo "SYNC_BRANCH=sync-rc/${SYNC_TARGET_BRANCH#refs/heads/}" >> $GITHUB_ENV | ||
# To keep the base branch in "create-pull-request", checkout with "BASE_BRANCH" and reset to "SYNC_TARGET_BRANCH" | ||
- name: Reset to sync target branch | ||
run: | | ||
git reset --hard origin/${{ env.SYNC_TARGET_BRANCH }} | ||
- name: Set git config | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "Github Actions" | ||
- name: Rebase on the base branch | ||
run: | | ||
for commit in $(git rev-list --left-only origin/${{ env.BASE_BRANCH }}...HEAD | tac); do | ||
git rebase $commit || git rebase --abort | ||
done | ||
- name: Create PR | ||
id: create_pr | ||
uses: peter-evans/create-pull-request@v3 | ||
|
@@ -69,4 +94,4 @@ jobs: | |
with: | ||
token: ${{ steps.generate-token.outputs.token }} | ||
pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }} | ||
merge-method: merge | ||
merge-method: squash |