This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (125 loc) · 3.68 KB
/
merge.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Merge
on:
push:
branches: [main]
paths-ignore:
- '*.md'
- '.graphics/**'
- '.github/**'
- '!.github/workflows/merge.yml'
workflow_dispatch:
inputs:
pr_no:
description: "PR-numbered container set to deploy"
type: number
required: true
jobs:
vars:
name: Output Semver and PR Number
outputs:
pr: ${{ steps.pr-number.outputs.pr }}
tag: ${{ steps.changelog.outputs.tag }}
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
# Outputs semver as steps.id.outputs.tag
- name: Conventional Changelog Update
uses: TriPSs/conventional-changelog-action@v4
id: changelog
with:
git-branch: refs/heads/${{ github.event.repository.default_branch }}
git-push: "false"
github-token: ${{ github.token }}
skip-commit: "true"
skip-on-empty: "false"
skip-version-file: "true"
# Create and push semver tag
- name: Create Tags
run: |
echo git tag ${{ steps.changelog.outputs.tag }}
echo git push origin --tag
# Get last merged (or current) PR number
- name: Get PR Number
id: pr-number
run: |
# Accept a provided PR number or use the API
if [ ! -z "${{ inputs.pr_no }}" ]; then
PR_NO="${{ inputs.pr_no }}"
else
HEAD=$(git log main --oneline | head -n1 | awk '{print $1}')
PR_NO=$(\
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/bcgov/quickstart-openshift/commits/${HEAD}/pulls \
| jq .[0].number
)
fi
echo -e "Last merged PR: ${PR_NO}"
# Validate PR number and send to GitHub Output
if [ "${PR_NO}" =~ ^[0-9]+$ ]; then
echo "No PR number not found"
exit 1
fi
echo "pr=${PR_NO}" >> $GITHUB_OUTPUT
# Add tag number and latest tags to PR image
retags:
name: Retag Images
needs: [vars]
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
package: [migrations, backend, frontend]
timeout-minutes: 1
steps:
- uses: shrink/actions-docker-registry-tag@v3
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ needs.vars.outputs.pr }}
tags: |
latest
${{ needs.vars.outputs.tag }}
deploy-test:
name: Deploy (test)
needs: [vars]
uses: ./.github/workflows/.deploy.yml
secrets: inherit
with:
environment: test
tag: ${{ needs.vars.outputs.pr }}
release: test
integration-e2e:
name: Integration and E2E Tests
needs: [deploy-test]
uses: ./.github/workflows/.tests.yml
with:
target: test
deploy-prod:
name: Deploy (prod)
needs: [integration-e2e, vars]
uses: ./.github/workflows/.deploy.yml
secrets: inherit
with:
environment: prod
tag: ${{ needs.vars.outputs.pr }}
release: prod
promote:
name: Promote Images
needs: [deploy-prod, vars]
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
package: [migrations, backend, frontend]
timeout-minutes: 1
steps:
- uses: shrink/actions-docker-registry-tag@v3
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ needs.vars.outputs.pr }}
tags: prod