-
Notifications
You must be signed in to change notification settings - Fork 8
145 lines (130 loc) · 4.26 KB
/
event_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
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
136
137
138
139
140
141
142
143
144
145
name: ⚡ Release
run-name: 'Release / ${{ github.event.head_commit.message }}'
on:
push:
branches:
- master
paths-ignore:
- '.github/**'
- 'docs/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'README.md'
- 'CHANGELOG.md'
- 'LICENSE'
- 'justfile'
- 'rustfmt.toml'
- '.editorconfig'
- '.pre-commit-config.yaml'
- '.terraformignore'
- '.env.example'
concurrency: deploy
permissions:
contents: write
id-token: write
packages: write
jobs:
# We skip the CI part here since it must have already run thanks to branch protection.
paths_filter:
name: Paths Filter
runs-on:
group: ${{ vars.RUN_GROUP }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
infra:
- '${{ vars.TF_DIRECTORY }}/**'
app:
- 'src/**'
outputs:
infra: ${{ steps.filter.outputs.infra }}
app: ${{ steps.filter.outputs.app }}
update_version:
name: Update Version
runs-on:
group: ${{ vars.RUN_GROUP }}
if: ${{ needs.paths_filter.outputs.app == 'true' }}
needs: [paths_filter]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.RELEASE_PAT }}
fetch-depth: 0
- name: Release
id: release
uses: WalletConnect/actions/github/update-rust-version/@2.1.4
with:
token: ${{ secrets.RELEASE_PAT }}
outputs:
version: ${{ steps.release.outputs.version }}
released_version:
name: Release Version ➠ ${{ needs.update_version.outputs.version }}
runs-on:
group: ${{ vars.RUN_GROUP }}
needs: [ update_version ]
steps:
- run: echo "Version = ${{ needs.update_version.outputs.version }}"
publish_image-staging:
name: Publish ${{ needs.update_version.outputs.version }} ❱❱ Staging ECR
uses: ./.github/workflows/sub-publish-image.yml
needs: [ update_version ]
with:
version: ${{ needs.update_version.outputs.version }}
aws-role-arn: ${{ vars.AWS_ROLE_STAGING }}
publish_image-prod:
name: Publish ${{ needs.update_version.outputs.version }} ❱❱ Prod ECR
uses: ./.github/workflows/sub-publish-image.yml
needs: [ update_version ]
with:
version: ${{ needs.update_version.outputs.version }}
aws-role-arn: ${{ vars.AWS_ROLE_PROD }}
get_version:
name: Get Version
runs-on:
group: ${{ vars.RUN_GROUP }}
needs: [ paths_filter, update_version, publish_image-staging, publish_image-prod ]
if: ${{ always() && !cancelled() && !failure() }}
steps:
- name: Get task definition from ECS
id: get_task
if: ${{ needs.paths_filter.outputs.app != 'true' }}
uses: WalletConnect/actions/aws/ecs/get-task-image/@2.1.4
with:
aws-role-arn: ${{ vars.AWS_ROLE_STAGING }}
aws-region: ${{ vars.AWS_REGION }}
task-definition-name: ${{ vars.IMAGE_NAME }}
container-name: ${{ vars.IMAGE_NAME }}
- name: Get target version
id: get_target_version
run: |
if [ "${{ needs.paths_filter.outputs.app }}" == "true" ]; then
echo "version=${{ needs.update_version.outputs.version }}" >> "$GITHUB_OUTPUT"
else
echo "version=${{ steps.get_task.outputs.tag }}" >> "$GITHUB_OUTPUT"
fi
outputs:
version: ${{ steps.get_target_version.outputs.version }}
used_version:
name: Version ➠ ${{ needs.get_version.outputs.version }}
if: ${{ always() && !cancelled() && !failure() }}
runs-on:
group: ${{ vars.RUN_GROUP }}
needs: [ get_version ]
steps:
- run: echo "Version = ${{ needs.get_version.outputs.version }}"
cd:
name: CD
uses: ./.github/workflows/sub-cd.yml
if: ${{ always() && !cancelled() && !failure() }}
needs: [paths_filter, get_version, publish_image-staging, publish_image-prod]
secrets: inherit
with:
deploy-infra: ${{ needs.paths_filter.outputs.infra == 'true' }}
deploy-app: ${{ needs.paths_filter.outputs.app == 'true' && needs.paths_filter.outputs.infra != 'true' }}
deploy-prod: true
version: ${{ needs.get_version.outputs.version }}