4
4
push :
5
5
branches :
6
6
- develop
7
- - main
8
- tags-ignore :
9
- - " **"
7
+ - feat/ordhook-sdk-js
10
8
paths-ignore :
11
- - " **/CHANGELOG.md"
9
+ - ' **/CHANGELOG.md'
12
10
pull_request :
13
11
workflow_dispatch :
14
12
13
+ concurrency :
14
+ group : ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
15
+ cancel-in-progress : true
16
+
15
17
jobs :
16
- build-publish :
18
+ test :
17
19
runs-on : ubuntu-latest
18
20
steps :
19
- - uses : actions/checkout@v2
21
+ - uses : actions/checkout@v4
20
22
with :
21
- token : ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
22
- fetch-depth : 0
23
23
persist-credentials : false
24
24
25
+ - name : Cache cargo
26
+ uses : actions/cache@v3
27
+ with :
28
+ path : |
29
+ ~/.cargo/bin/
30
+ ~/.cargo/registry/index/
31
+ ~/.cargo/registry/cache/
32
+ ~/.cargo/git/db/
33
+ target/
34
+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
35
+
25
36
- name : Cargo test
26
37
run : |
27
38
rustup update
28
- cargo test --all
39
+ RUST_BACKTRACE=1 cargo test --all -- --test-threads=1
40
+
41
+ build-publish :
42
+ runs-on : ubuntu-latest
43
+ needs : test
44
+ outputs :
45
+ docker_image_digest : ${{ steps.docker_push.outputs.digest }}
46
+ new_release_published : ${{ steps.semantic.outputs.new_release_published }}
47
+ steps :
48
+ - uses : actions/checkout@v4
49
+ with :
50
+ persist-credentials : false
29
51
30
52
- name : Semantic Release
31
- uses : cycjimmy/semantic-release-action@v3
53
+ uses : cycjimmy/semantic-release-action@v4
32
54
id : semantic
33
55
# Only run on non-PR events or only PRs that aren't from forks
34
56
if : github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
35
57
env :
36
- GITHUB_TOKEN : ${{ secrets.GH_TOKEN || secrets. GITHUB_TOKEN }}
58
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
37
59
SEMANTIC_RELEASE_PACKAGE : ${{ github.event.repository.name }}
38
60
with :
39
61
semantic_version : 19
@@ -42,15 +64,21 @@ jobs:
42
64
@semantic-release/git@10.0.1
43
65
conventional-changelog-conventionalcommits@6.1.0
44
66
67
+ - name : Checkout tag
68
+ if : steps.semantic.outputs.new_release_version != ''
69
+ uses : actions/checkout@v4
70
+ with :
71
+ persist-credentials : false
72
+ ref : v${{ steps.semantic.outputs.new_release_version }}
73
+
45
74
- name : Set up Docker Buildx
46
- uses : docker/setup-buildx-action@v1
75
+ uses : docker/setup-buildx-action@v3
47
76
48
77
- name : Docker Meta
49
78
id : meta
50
- uses : docker/metadata-action@v4
79
+ uses : docker/metadata-action@v5
51
80
with :
52
81
images : |
53
- blockstack/${{ github.event.repository.name }}
54
82
hirosystems/${{ github.event.repository.name }}
55
83
tags : |
56
84
type=ref,event=branch
@@ -59,18 +87,134 @@ jobs:
59
87
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic.outputs.new_release_version }},enable=${{ steps.semantic.outputs.new_release_version != '' }}
60
88
type=raw,value=latest,enable={{is_default_branch}}
61
89
62
- - name : Login to DockerHub
63
- uses : docker/login-action@v2
90
+ - name : Log in to DockerHub
91
+ uses : docker/login-action@v3
64
92
with :
65
93
username : ${{ secrets.DOCKERHUB_USERNAME }}
66
94
password : ${{ secrets.DOCKERHUB_PASSWORD }}
67
95
68
- - name : Build/Tag/Push Image
69
- uses : docker/build-push-action@v2
96
+ - name : Build/Push Image
97
+ uses : docker/build-push-action@v5
98
+ id : docker_push
70
99
with :
71
100
context : .
72
101
tags : ${{ steps.meta.outputs.tags }}
73
102
labels : ${{ steps.meta.outputs.labels }}
74
103
file : ./dockerfiles/components/ordhook.dockerfile
104
+ cache-from : type=gha
105
+ cache-to : type=gha,mode=max
75
106
# Only push if (there's a new release on main branch, or if building a non-main branch) and (Only run on non-PR events or only PRs that aren't from forks)
76
- push : ${{ (github.ref != 'refs/heads/master' || steps.semantic.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
107
+ push : ${{ (github.ref != 'refs/heads/main' || steps.semantic.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
108
+
109
+ deploy-dev :
110
+ runs-on : ubuntu-latest
111
+ strategy :
112
+ matrix :
113
+ k8s-env : [mainnet]
114
+ needs : build-publish
115
+ if : github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
116
+ env :
117
+ DEPLOY_ENV : dev
118
+ environment :
119
+ name : Development-${{ matrix.k8s-env }}
120
+ url : https://platform.dev.hiro.so/
121
+ steps :
122
+ - name : Checkout actions repo
123
+ uses : actions/checkout@v4
124
+ with :
125
+ ref : main
126
+ token : ${{ secrets.GH_TOKEN }}
127
+ repository : ${{ secrets.DEVOPS_ACTIONS_REPO }}
128
+
129
+ - name : Deploy Ordhook build to Dev ${{ matrix.k8s-env }}
130
+ uses : ./actions/deploy
131
+ with :
132
+ docker_tag : ${{ needs.build-publish.outputs.docker_image_digest }}
133
+ file_pattern : manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml
134
+ gh_token : ${{ secrets.GH_TOKEN }}
135
+
136
+ auto-approve-dev :
137
+ runs-on : ubuntu-latest
138
+ if : needs.build-publish.outputs.new_release_published == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
139
+ needs : build-publish
140
+ steps :
141
+ - name : Approve pending deployments
142
+ run : |
143
+ sleep 5
144
+ ENV_IDS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" | jq -r '[.[].environment.id // empty]')
145
+ if [[ "${ENV_IDS}" != "[]" ]]; then
146
+ curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" -d "{\"environment_ids\":${ENV_IDS},\"state\":\"approved\",\"comment\":\"auto approve\"}"
147
+ fi
148
+
149
+ deploy-staging :
150
+ runs-on : ubuntu-latest
151
+ strategy :
152
+ matrix :
153
+ k8s-env : [mainnet]
154
+ needs :
155
+ - build-publish
156
+ - deploy-dev
157
+ if : github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
158
+ env :
159
+ DEPLOY_ENV : stg
160
+ environment :
161
+ name : Staging-${{ matrix.k8s-env }}
162
+ url : https://platform.stg.hiro.so/
163
+ steps :
164
+ - name : Checkout actions repo
165
+ uses : actions/checkout@v4
166
+ with :
167
+ ref : main
168
+ token : ${{ secrets.GH_TOKEN }}
169
+ repository : ${{ secrets.DEVOPS_ACTIONS_REPO }}
170
+
171
+ - name : Deploy Chainhook build to Stg ${{ matrix.k8s-env }}
172
+ uses : ./actions/deploy
173
+ with :
174
+ docker_tag : ${{ needs.build-publish.outputs.docker_image_digest }}
175
+ file_pattern : manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml
176
+ gh_token : ${{ secrets.GH_TOKEN }}
177
+
178
+ auto-approve-stg :
179
+ runs-on : ubuntu-latest
180
+ if : needs.build-publish.outputs.new_release_published == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
181
+ needs :
182
+ - build-publish
183
+ - deploy-dev
184
+ steps :
185
+ - name : Approve pending deployments
186
+ run : |
187
+ sleep 5
188
+ ENV_IDS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" | jq -r '[.[].environment.id // empty]')
189
+ if [[ "${ENV_IDS}" != "[]" ]]; then
190
+ curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" -d "{\"environment_ids\":${ENV_IDS},\"state\":\"approved\",\"comment\":\"auto approve\"}"
191
+ fi
192
+
193
+ deploy-prod :
194
+ runs-on : ubuntu-latest
195
+ strategy :
196
+ matrix :
197
+ k8s-env : [mainnet,testnet]
198
+ needs :
199
+ - build-publish
200
+ - deploy-staging
201
+ if : needs.build-publish.outputs.new_release_published == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
202
+ env :
203
+ DEPLOY_ENV : prd
204
+ environment :
205
+ name : Production-${{ matrix.k8s-env }}
206
+ url : https://platform.hiro.so/
207
+ steps :
208
+ - name : Checkout actions repo
209
+ uses : actions/checkout@v4
210
+ with :
211
+ ref : main
212
+ token : ${{ secrets.GH_TOKEN }}
213
+ repository : ${{ secrets.DEVOPS_ACTIONS_REPO }}
214
+
215
+ - name : Deploy Ordhook build to Prd ${{ matrix.k8s-env }}
216
+ uses : ./actions/deploy
217
+ with :
218
+ docker_tag : ${{ needs.build-publish.outputs.docker_image_digest }}
219
+ file_pattern : manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml
220
+ gh_token : ${{ secrets.GH_TOKEN }}
0 commit comments