Skip to content

Commit 887aeaf

Browse files
committedDec 8, 2023
feat: inital changes to support subenv deployments
1 parent f972a4c commit 887aeaf

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed
 

‎.github/workflows/ci.yaml

+35-25
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ on:
66
- develop
77
- feat/ordhook-sdk-js
88
paths-ignore:
9-
- '**/CHANGELOG.md'
9+
- "**/CHANGELOG.md"
1010
pull_request:
1111
workflow_dispatch:
1212

1313
concurrency:
1414
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
1515
cancel-in-progress: true
1616

17+
env:
18+
DOCKER_IMAGE: hirosystems/${{ github.event.repository.name }}
19+
1720
jobs:
1821
test:
1922
runs-on: ubuntu-latest
@@ -41,7 +44,7 @@ jobs:
4144
- name: Upload coverage reports to Codecov
4245
uses: codecov/codecov-action@v3
4346
env:
44-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
47+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4548

4649
build-publish:
4750
runs-on: ubuntu-latest
@@ -84,7 +87,7 @@ jobs:
8487
uses: docker/metadata-action@v5
8588
with:
8689
images: |
87-
hirosystems/${{ github.event.repository.name }}
90+
${{ env.DOCKER_IMAGE }}
8891
tags: |
8992
type=ref,event=branch
9093
type=ref,event=pr
@@ -115,27 +118,30 @@ jobs:
115118
runs-on: ubuntu-latest
116119
strategy:
117120
matrix:
118-
k8s-env: [mainnet]
121+
network: [mainnet]
122+
subenv: [blue]
119123
needs: build-publish
120124
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
121125
env:
122126
DEPLOY_ENV: dev
123127
environment:
124-
name: Development-${{ matrix.k8s-env }}
128+
name: Development-${{ matrix.network }}-${{ matrix.subenv }}
125129
url: https://platform.dev.hiro.so/
126130
steps:
127131
- name: Checkout actions repo
128132
uses: actions/checkout@v4
129133
with:
130-
ref: main
134+
ref: feat/subenvs
131135
token: ${{ secrets.GH_TOKEN }}
132136
repository: ${{ secrets.DEVOPS_ACTIONS_REPO }}
133137

134-
- name: Deploy Ordhook build to Dev ${{ matrix.k8s-env }}
138+
- name: Deploy Ordhook build to Dev ${{ matrix.network }} ${{ matrix.subenv }}
135139
uses: ./actions/deploy
136140
with:
137-
docker_tag: ${{ needs.build-publish.outputs.docker_image_digest }}
138-
file_pattern: manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml
141+
docker_image: ${{ env.DOCKER_IMAGE }}
142+
docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }}
143+
dir_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}
144+
subenv: ${{ matrix.subenv }}
139145
gh_token: ${{ secrets.GH_TOKEN }}
140146

141147
auto-approve-dev:
@@ -146,38 +152,40 @@ jobs:
146152
- name: Approve pending deployments
147153
run: |
148154
sleep 5
149-
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]')
155+
ENV_ID=$(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 '.[0].environment.id // empty')
150156
if [[ "${ENV_IDS}" != "[]" ]]; then
151-
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\"}"
157+
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_ID}],\"state\":\"approved\",\"comment\":\"auto approve\"}"
152158
fi
153159
154160
deploy-staging:
155161
runs-on: ubuntu-latest
156162
strategy:
157163
matrix:
158-
k8s-env: [mainnet]
164+
network: [mainnet]
165+
subenv: [blue]
159166
needs:
160167
- build-publish
161168
- deploy-dev
162169
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
163170
env:
164171
DEPLOY_ENV: stg
165172
environment:
166-
name: Staging-${{ matrix.k8s-env }}
173+
name: Staging-${{ matrix.network }}-${{ matrix.subenv }}
167174
url: https://platform.stg.hiro.so/
168175
steps:
169176
- name: Checkout actions repo
170177
uses: actions/checkout@v4
171178
with:
172-
ref: main
179+
ref: feat/subenvs
173180
token: ${{ secrets.GH_TOKEN }}
174181
repository: ${{ secrets.DEVOPS_ACTIONS_REPO }}
175182

176-
- name: Deploy Chainhook build to Stg ${{ matrix.k8s-env }}
183+
- name: Deploy Ordhook build to Stg ${{ matrix.network }} ${{ matrix.subenv }}
177184
uses: ./actions/deploy
178185
with:
179-
docker_tag: ${{ needs.build-publish.outputs.docker_image_digest }}
180-
file_pattern: manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml
186+
docker_image: ${{ env.DOCKER_IMAGE }}
187+
docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }}
188+
file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml
181189
gh_token: ${{ secrets.GH_TOKEN }}
182190

183191
auto-approve-stg:
@@ -190,36 +198,38 @@ jobs:
190198
- name: Approve pending deployments
191199
run: |
192200
sleep 5
193-
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]')
201+
ENV_ID=$(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 '.[0].environment.id // empty')
194202
if [[ "${ENV_IDS}" != "[]" ]]; then
195-
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\"}"
203+
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_ID}],\"state\":\"approved\",\"comment\":\"auto approve\"}"
196204
fi
197205
198206
deploy-prod:
199207
runs-on: ubuntu-latest
200208
strategy:
201209
matrix:
202-
k8s-env: [mainnet,testnet]
210+
network: [mainnet]
211+
subenv: [blue, green]
203212
needs:
204213
- build-publish
205214
- deploy-staging
206215
if: needs.build-publish.outputs.new_release_published == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
207216
env:
208217
DEPLOY_ENV: prd
209218
environment:
210-
name: Production-${{ matrix.k8s-env }}
219+
name: Production-${{ matrix.network }}-${{ matrix.subenv }}
211220
url: https://platform.hiro.so/
212221
steps:
213222
- name: Checkout actions repo
214223
uses: actions/checkout@v4
215224
with:
216-
ref: main
225+
ref: feat/subenvs
217226
token: ${{ secrets.GH_TOKEN }}
218227
repository: ${{ secrets.DEVOPS_ACTIONS_REPO }}
219228

220-
- name: Deploy Ordhook build to Prd ${{ matrix.k8s-env }}
229+
- name: Deploy Ordhook build to Prd ${{ matrix.network }} ${{ matrix.subenv }}
221230
uses: ./actions/deploy
222231
with:
223-
docker_tag: ${{ needs.build-publish.outputs.docker_image_digest }}
224-
file_pattern: manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml
232+
docker_image: ${{ env.DOCKER_IMAGE }}
233+
docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }}
234+
file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml
225235
gh_token: ${{ secrets.GH_TOKEN }}

0 commit comments

Comments
 (0)