Skip to content

Commit 0eff5c9

Browse files
authored
Merge pull request #6 from initia-labs/feat/deploy-actions
feat: github actions for building and deploying informative
2 parents 7a92eaa + 9f62d52 commit 0eff5c9

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build, Test, Push & Deploy Informative Indexer Docker Image
2+
3+
env:
4+
GIT_SHA: ${{ github.sha }}
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- "informative-indexer/**"
12+
- "dockerfiles/Dockerfile.informative"
13+
- ".github/workflows/informative-indexer-build.yml"
14+
15+
jobs:
16+
push:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
sha_short: ${{ steps.vars.outputs.sha_short }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Set outputs
24+
id: vars
25+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
26+
27+
- id: auth
28+
name: Authenticate to Google Cloud
29+
uses: "google-github-actions/auth@v1"
30+
with:
31+
credentials_json: "${{ secrets.ALLES_GOOGLE_CREDENTIALS }}"
32+
token_format: "access_token"
33+
34+
- name: Authenticate to Docker Registry
35+
run: echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://asia-southeast1-docker.pkg.dev
36+
37+
- name: Setup Go
38+
uses: actions/setup-go@v5
39+
with:
40+
go-version: '1.22.7'
41+
cache: true
42+
43+
- name: Run Tests
44+
run: |
45+
cd informative-indexer
46+
go test -v ./...
47+
48+
- name: Build Informative Indexer Image
49+
run: |
50+
docker build -t informative-indexer:${{ steps.vars.outputs.sha_short }} -f dockerfiles/Dockerfile.informative .
51+
docker tag informative-indexer:${{ steps.vars.outputs.sha_short }} asia-southeast1-docker.pkg.dev/alles-share/shared-docker-images/core-indexer/initia-informative-indexer:${{ steps.vars.outputs.sha_short }}
52+
53+
- name: Push Informative Indexer Image
54+
run: docker push asia-southeast1-docker.pkg.dev/alles-share/shared-docker-images/core-indexer/initia-informative-indexer:${{ steps.vars.outputs.sha_short }}
55+
56+
deploy:
57+
runs-on: ubuntu-latest
58+
needs: push
59+
steps:
60+
- id: auth
61+
name: Authenticate to Google Cloud
62+
uses: "google-github-actions/auth@v1"
63+
with:
64+
credentials_json: "${{ secrets.ALLES_GOOGLE_CREDENTIALS }}"
65+
token_format: "access_token"
66+
67+
- id: token
68+
name: Get GitHub Token
69+
run: echo "github_token=$(gcloud secrets versions access latest --secret=github-allesci-token --project "alles-share")" >> $GITHUB_OUTPUT
70+
71+
- id: dispatch-initiation-2
72+
name: Dispatch to alleslabs/celatone-infrastructure for initiation-2
73+
uses: indiesdev/[email protected]
74+
with:
75+
url: https://api.github.com/repos/alleslabs/celatone-infrastructure/dispatches
76+
method: "POST"
77+
headers: '{ "Accept": "application/vnd.github.everest-preview+json", "Authorization": "token ${{ steps.token.outputs.github_token }}" }'
78+
body: '{ "event_type": "informative_indexer", "client_payload": { "network": "initia", "chain_id": "initiation-2", "sha_short": ${{ needs.push.outputs.sha_short }} } }'
79+
timeout: 10000
80+
log-response: true
81+
retries: 3

dockerfiles/Dockerfile.informative

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM golang:1.22
2+
3+
WORKDIR /
4+
COPY informative-indexer /informative-indexer
5+
6+
WORKDIR /informative-indexer
7+
RUN go build -o /informative-indexer.bin .
8+
9+
CMD ["/informative-indexer.bin"]

0 commit comments

Comments
 (0)