-
Notifications
You must be signed in to change notification settings - Fork 1.4k
46 lines (39 loc) · 1.35 KB
/
create-hotfix-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
name: Create hotfix branch
on:
workflow_dispatch:
jobs:
create_branch:
runs-on: ubuntu-latest
steps:
- name: Generate a token
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.HYPERSWITCH_BOT_APP_ID }}
private-key: ${{ secrets.HYPERSWITCH_BOT_APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}
- name: Check if the input is valid tag
shell: bash
run: |
if [[ ${{github.ref}} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::notice::${{github.ref}} is a valid tag."
else
echo "::error::${{github.ref}} is not a valid tag."
exit 1
fi
- name: Create hotfix branch
shell: bash
run: |
HOTFIX_BRANCH="hotfix-${GITHUB_REF#refs/tags/v}"
if git switch --create "$HOTFIX_BRANCH"; then
git push origin "$HOTFIX_BRANCH"
echo "::notice::Created hotfix branch: $HOTFIX_BRANCH"
else
echo "::error::Failed to create hotfix branch"
exit 1
fi