Skip to content

Commit 0d145df

Browse files
author
Ludo Galabru
authored
feat: ordhook-sdk-js refactoring (#186)
1 parent 632c897 commit 0d145df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5262
-9164
lines changed

.github/workflows/ci.yaml

+163-19
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,58 @@ on:
44
push:
55
branches:
66
- develop
7-
- main
8-
tags-ignore:
9-
- "**"
7+
- feat/ordhook-sdk-js
108
paths-ignore:
11-
- "**/CHANGELOG.md"
9+
- '**/CHANGELOG.md'
1210
pull_request:
1311
workflow_dispatch:
1412

13+
concurrency:
14+
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
15+
cancel-in-progress: true
16+
1517
jobs:
16-
build-publish:
18+
test:
1719
runs-on: ubuntu-latest
1820
steps:
19-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
2022
with:
21-
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
22-
fetch-depth: 0
2323
persist-credentials: false
2424

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+
2536
- name: Cargo test
2637
run: |
2738
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
2951

3052
- name: Semantic Release
31-
uses: cycjimmy/semantic-release-action@v3
53+
uses: cycjimmy/semantic-release-action@v4
3254
id: semantic
3355
# Only run on non-PR events or only PRs that aren't from forks
3456
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
3557
env:
36-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3759
SEMANTIC_RELEASE_PACKAGE: ${{ github.event.repository.name }}
3860
with:
3961
semantic_version: 19
@@ -42,15 +64,21 @@ jobs:
4264
@semantic-release/git@10.0.1
4365
conventional-changelog-conventionalcommits@6.1.0
4466
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+
4574
- name: Set up Docker Buildx
46-
uses: docker/setup-buildx-action@v1
75+
uses: docker/setup-buildx-action@v3
4776

4877
- name: Docker Meta
4978
id: meta
50-
uses: docker/metadata-action@v4
79+
uses: docker/metadata-action@v5
5180
with:
5281
images: |
53-
blockstack/${{ github.event.repository.name }}
5482
hirosystems/${{ github.event.repository.name }}
5583
tags: |
5684
type=ref,event=branch
@@ -59,18 +87,134 @@ jobs:
5987
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic.outputs.new_release_version }},enable=${{ steps.semantic.outputs.new_release_version != '' }}
6088
type=raw,value=latest,enable={{is_default_branch}}
6189
62-
- name: Login to DockerHub
63-
uses: docker/login-action@v2
90+
- name: Log in to DockerHub
91+
uses: docker/login-action@v3
6492
with:
6593
username: ${{ secrets.DOCKERHUB_USERNAME }}
6694
password: ${{ secrets.DOCKERHUB_PASSWORD }}
6795

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
7099
with:
71100
context: .
72101
tags: ${{ steps.meta.outputs.tags }}
73102
labels: ${{ steps.meta.outputs.labels }}
74103
file: ./dockerfiles/components/ordhook.dockerfile
104+
cache-from: type=gha
105+
cache-to: type=gha,mode=max
75106
# 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

Comments
 (0)