-
Notifications
You must be signed in to change notification settings - Fork 2k
69 lines (62 loc) · 1.76 KB
/
create-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
67
68
69
name: "Create release branch"
on:
workflow_dispatch:
inputs:
release_version:
required: true
type: string
default: '0.0'
source_branch:
required: false
type: string
default: 'main'
branch_prefix:
required: false
type: string
default: 'release-'
update:
type: boolean
default: false
dry_run:
type: boolean
default: false
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
create:
name: Create release branch
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout NIC repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ inputs.source_branch }}
- name: Create new release branch
run: |
branch="${{ inputs.branch_prefix }}${{ inputs.release_version }}"
if git rev-parse --verify remotes/origin/${branch}; then
git checkout ${branch}
git pull
if ${{ inputs.update }}; then
echo "Updating from ${{ inputs.source_branch }}."
git merge -Xtheirs ${{ inputs.source_branch }} -m "chore: Merge branch ${{ inputs.source_branch }} into ${branch}"
else
echo "UPDATE not requested. Not making any changes"
fi
else
git checkout -b ${branch}
fi
echo "Pushing to branch $branch"
if ! ${{ inputs.dry_run }}; then
git push origin "${branch}"
else
echo "DRY RUN not making any changes"
git push --dry-run origin "${branch}"
fi
env:
GITHUB_TOKEN: ${{ secrets.NGINX_PAT }}