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.
add sync-rc workflow (autowarefoundation#393)
- Loading branch information
1 parent
e22bf93
commit 97f4f39
Showing
1 changed file
with
72 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: sync rc | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "rc/*" | ||
types: | ||
- closed | ||
workflow_dispatch: | ||
|
||
env: | ||
BASE_BRANCH: main | ||
SYNC_BRANCH: sync-rc | ||
|
||
jobs: | ||
sync-rc: | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ env.BASE_BRANCH }} | ||
fetch-depth: 0 | ||
|
||
- name: Generate token | ||
uses: tibdex/github-app-token@v1 | ||
id: generate-token | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: Set SYNC_TARGET_BRANCH | ||
run: | | ||
echo "SYNC_TARGET_BRANCH=${{ github.head_ref }}" >> $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: Create PR | ||
id: create_pr | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ steps.generate-token.outputs.token }} | ||
commit-message: sync rc | ||
committer: GitHub <noreply@github.com> | ||
author: GitHub <noreply@github.com> | ||
signoff: false | ||
base: ${{ env.BASE_BRANCH }} | ||
branch: ${{ env.SYNC_BRANCH }} | ||
delete-branch: true | ||
title: sync rc | ||
body: | | ||
sync rc | ||
labels: | | ||
sync-rc | ||
draft: false | ||
|
||
- name: Check outputs | ||
run: | | ||
echo "Pull Request Number - ${{ steps.create_pr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.create_pr.outputs.pull-request-url }}" | ||
- name: Enable Auto-merge | ||
if: steps.create_pr.outputs.pull-request-operation == 'created' | ||
uses: peter-evans/enable-pull-request-automerge@v1 | ||
with: | ||
token: ${{ steps.generate-token.outputs.token }} | ||
pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }} | ||
merge-method: merge |