-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (63 loc) · 2.09 KB
/
hotfix.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
70
71
72
name: "Hotfix: Tag and build"
on:
push:
branches:
- hotfix/v*
jobs:
check-untagged:
runs-on: ubuntu-latest
outputs:
untagged: ${{ !startsWith(env.MATCHING_TAGS, 'v') }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check untagged (don't run for branch creation)
id: get-matching-tags
shell: bash
run: |
MATCHING_TAGS=$(git tag --contains HEAD)
echo "Matching tags: $MATCHING_TAGS"
echo "MATCHING_TAGS=$MATCHING_TAGS" >> $GITHUB_ENV
tag:
runs-on: ubuntu-latest
needs: check-untagged
if: needs.check-untagged.outputs.untagged == 'true'
outputs:
version: ${{ steps.bump-semver.outputs.new_version }}
steps:
- uses: actions/checkout@v3
- name: Get minor version of branch
shell: bash
run: |
echo "${{ needs.check-untagged.outputs.untagged }}"
BRANCH_VERSION=${GITHUB_REF#refs/*/hotfix/}
BRANCH_VERSION=${BRANCH_VERSION%.*}
echo "BRANCH_VERSION=$BRANCH_VERSION" >> $GITHUB_ENV
- name: Get latest patch version tag for minor version
id: get-latest-tag
uses: oprypin/find-latest-tag@v1
with:
repository: communitiesuk/eip-ero-print-api
releases-only: false
prefix: '${{ env.BRANCH_VERSION }}'
- name: Bump patch version tag
uses: cabinetoffice/action-bump-semver@v1
id: bump-semver
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: patch
- name: Push version tag
run: |
tag=${{ steps.bump-semver.outputs.new_version }}
message='${{ github.event.head_commit.message }}'
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${tag}" -m "${message}"
git push origin "${tag}"
build-and-push:
needs: tag
uses: ./.github/workflows/build-and-push.yml
with:
version: ${{ needs.tag.outputs.version }}
secrets: inherit