-
Notifications
You must be signed in to change notification settings - Fork 4
66 lines (59 loc) · 2.05 KB
/
merge-release-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
59
60
61
62
63
64
65
66
name: Merge release branch into main
on:
workflow_call:
inputs:
version:
type: string
description: The release branch version to merge into main
required: true
repo:
type: string
description: The repository to create the PR (org/repo format)
required: true
workflow_dispatch:
inputs:
version:
type: string
description: The release branch version to merge into main
required: true
repo:
type: string
description: The repository to create the PR (org/repo format)
required: true
defaults:
run:
shell: bash
jobs:
merge-release-branch:
name: Submit PR to merge release branch into main
runs-on: ubuntu-latest
steps:
- name: Create PR
id: cpr
run: |
pr_url=$(gh pr create \
--title "chore: Merge release/${{ inputs.version }} into main" \
--body "Open new development line" \
--head release/${{ inputs.version }} \
--base main \
--label internal \
-R ${{ inputs.repo }} \
)
echo "pull-request-operation=created" >> $GITHUB_OUTPUT
pr_number="${pr_url##*/pull/}"
echo "pull-request-number=$pr_number" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
- name: Enable auto merge for the pull request
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
run: >
gh pr merge "${{ steps.cpr.outputs.pull-request-number }}"
--subject "chore: Merge release/${{ inputs.version }} into main (#${{ steps.cpr.outputs.pull-request-number }})"
--repo "${{ inputs.repo }}"
--auto
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
- name: Add the PR as annotation to workflow run
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
run: >
echo "::notice:: Created PR: https://github.com/${{ inputs.repo }}/pull/${{ steps.cpr.outputs.pull-request-number }}"