|
| 1 | +# This file is automatically synced from: |
| 2 | +# https://github.com/autowarefoundation/sync-file-templates |
| 3 | +# To make changes, update the source repository and follow the guidelines in its README. |
| 4 | + |
| 5 | +# Opens a PR that merges one branch of this repo into another (e.g. main -> humble). |
| 6 | +# |
| 7 | +# Trigger: manual (workflow_dispatch). |
| 8 | +# Inputs: |
| 9 | +# base-branch The branch the PR targets — i.e. the branch that receives changes. Default: humble. |
| 10 | +# sync-target-branch The branch the PR's contents come from. Default: main. |
| 11 | +# The PR working branch is derived as: sync-<sync-target-branch>-to-<base-branch>. |
| 12 | +# |
| 13 | +# Auth: uses a GitHub App token (APP_ID / PRIVATE_KEY secrets) so the PR can be |
| 14 | +# created/updated and so workflow files under .github/workflows/ can be synced |
| 15 | +# (the default GITHUB_TOKEN lacks the `workflow` scope). |
| 16 | +name: sync-branches |
| 17 | + |
| 18 | +on: |
| 19 | + workflow_dispatch: |
| 20 | + inputs: |
| 21 | + base-branch: |
| 22 | + description: Base branch of the sync PR (the branch that receives changes). |
| 23 | + required: false |
| 24 | + default: humble |
| 25 | + type: string |
| 26 | + sync-target-branch: |
| 27 | + description: Branch or commit SHA to sync from (the source of changes). |
| 28 | + required: false |
| 29 | + default: main |
| 30 | + type: string |
| 31 | + |
| 32 | +concurrency: |
| 33 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ inputs.sync-target-branch }}-${{ inputs.base-branch }} |
| 34 | + cancel-in-progress: true |
| 35 | + |
| 36 | +jobs: |
| 37 | + sync-branches: |
| 38 | + runs-on: ubuntu-22.04 |
| 39 | + steps: |
| 40 | + - name: Validate inputs and compute PR branch name |
| 41 | + id: prepare |
| 42 | + run: | |
| 43 | + if [ "${{ inputs.base-branch }}" = "${{ inputs.sync-target-branch }}" ]; then |
| 44 | + echo "::error::base-branch and sync-target-branch must differ (got '${{ inputs.base-branch }}')." |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + echo "pr-branch=sync-${{ inputs.sync-target-branch }}-to-${{ inputs.base-branch }}" >> "$GITHUB_OUTPUT" |
| 48 | + shell: bash |
| 49 | + |
| 50 | + - name: Generate token |
| 51 | + id: generate-token |
| 52 | + uses: actions/create-github-app-token@v2 |
| 53 | + with: |
| 54 | + app-id: ${{ secrets.APP_ID }} |
| 55 | + private-key: ${{ secrets.PRIVATE_KEY }} |
| 56 | + |
| 57 | + - name: Run sync-branches |
| 58 | + uses: autowarefoundation/autoware-github-actions/sync-branches@v1 |
| 59 | + with: |
| 60 | + token: ${{ steps.generate-token.outputs.token }} |
| 61 | + base-branch: ${{ inputs.base-branch }} |
| 62 | + sync-pr-branch: ${{ steps.prepare.outputs.pr-branch }} |
| 63 | + sync-target-repository: https://github.com/${{ github.repository }}.git |
| 64 | + sync-target-branch: ${{ inputs.sync-target-branch }} |
| 65 | + pr-title: "chore: sync ${{ inputs.sync-target-branch }} into ${{ inputs.base-branch }}" |
| 66 | + pr-labels: | |
| 67 | + tag:bot |
| 68 | + tag:sync-branches |
0 commit comments