-
Notifications
You must be signed in to change notification settings - Fork 30
80 lines (68 loc) · 2.77 KB
/
release_create_hotfix_branch.yaml
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
70
71
72
73
74
75
76
77
78
79
80
name: "🩹 Create Release Hotfix Branch"
on:
workflow_dispatch:
inputs:
version:
type: string
description: "Version to use as hotfix base, patch version will be increased, in format 'vX.Y.Z'"
cherry_pick_commits:
type: string
description: "Commits to cherry pick, separated by space"
jobs:
create_release_hotfix_branch:
name: "Create Release Hotfix"
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
branch: "release/${{ github.event.inputs.version }}"
steps:
- name: Checkout code
id: checkout
uses: actions/checkout@v2
with:
ref: "${{ env.branch }}"
fetch-depth: 0
- name: Create hotfix branch
id: create_branch
working-directory: .github/.scripts
run: |
version=${{ github.event.inputs.version }}
hotfix_version=$(./shift_version.sh ${version} patch)
hotfix_branch="release/${hotfix_version}"
git checkout -b ${hotfix_branch} "${{ env.branch }}"
git push origin ${hotfix_branch}
echo "hotfix_version=${hotfix_version}" >> $GITHUB_OUTPUT
echo "hotfix_branch=${hotfix_branch}" >> $GITHUB_OUTPUT
- name: Create hotfix PR Branch
id: create_pr_branch
run: |
hotfix_pr_branch="hotfix/${{ steps.create_branch.outputs.hotfix_version }}"
git checkout -b ${hotfix_pr_branch} ${{ steps.create_branch.outputs.hotfix_branch }}
git push origin ${hotfix_pr_branch}
echo "hotfix_pr_branch=${hotfix_pr_branch}" >> $GITHUB_OUTPUT
- name: Setup git user
id: setup_git_user
if: ${{ github.event.inputs.cherry_pick_commits != '' }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Cherry pick commits
id: cherry_pick
if: ${{ github.event.inputs.cherry_pick_commits != '' }}
run: |
git cherry-pick ${{ github.event.inputs.cherry_pick_commits }}
git push origin ${{ steps.create_pr_branch.outputs.hotfix_pr_branch }}
- name: Create pull request
id: create_pull_request
if: ${{ github.event.inputs.cherry_pick_commits != '' }}
run: |
gh pr create \
--repo ${{ github.repository_owner }}/${{ github.event.repository.name }} \
--base ${{ steps.create_branch.outputs.hotfix_branch }} \
--head ${{ steps.create_pr_branch.outputs.hotfix_pr_branch }} \
--title "Hotfix ${{ steps.create_branch.outputs.hotfix_version }}" \
--body "Hotfix ${{ steps.create_branch.outputs.hotfix_version }}"
env:
GH_TOKEN: ${{ secrets.ROBOT_GITHUB_PUBLIC_REPO_CREATE_HOTFIX_TOKEN }}