-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (66 loc) · 2.18 KB
/
_service_release.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
name: Release service
on:
workflow_dispatch:
inputs:
service_name:
description: 'Service name'
required: true
type: choice
options:
- a
- b
automatic_deploy_to_dev:
description: "Automatically deploy this release to DEV environment"
type: boolean
workflow_call:
inputs:
service_name:
required: true
type: string
automatic_deploy_to_dev:
type: boolean
jobs:
release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/${{ inputs.service_name }}/
outputs:
next_tag: ${{ steps.tag_image.outputs.next_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Check for successful tests
env:
GH_TOKEN: ${{ github.token }}
run: |
# Check if the github ref has a successful test status
if ! gh api repos/${{ github.repository }}/commits/${{ github.ref }}/check-runs | jq '.check_runs[] | select(.conclusion == "success")' > /dev/null; then
echo "No successful tests found for ${{ github.ref }}"
exit 1
fi
- name: Build docker image
run: make build
- name: Tag the docker image
id: tag_image
run: PRERELEASE=${{ github.event_name == 'workflow_dispatch' }} make release
- uses: thejeff77/[email protected]
with:
tag: ${{ steps.tag_image.outputs.next_tag }}
message: '"${{ steps.tag_image.outputs.next_tag }}: PR #${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}"'
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_image.outputs.next_tag }}
generate_release_notes: true
prerelease: ${{ github.event_name == 'workflow_dispatch' }}
automatic_deploy:
if: ${{ inputs.automatic_deploy_to_dev == true }}
needs: release
uses: ./.github/workflows/deploy.yaml
with:
checkout_ref: ${{ needs.release.outputs.next_tag }}
service_name: ${{ inputs.service_name }}
environment: dev