-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (118 loc) Β· 4.26 KB
/
deploy.yml
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
name: π Deploy
on:
workflow_dispatch:
push:
branches:
- main
- staging
concurrency:
group: ${{ github.ref }}-deploy
env:
CI: true
permissions:
id-token: write
contents: write
defaults:
run:
shell: bash
jobs:
deploy:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- uses: dorny/paths-filter@v3
id: changes
with:
base: ${{ github.ref }}
list-files: 'shell'
filters: |
erpc:
- 'packages/erpc/erpc.yaml'
- 'packages/erpc/Dockerfile'
ponder:
- 'packages/ponder/**'
dockerImage:
- 'packages/erpc/erpc.yaml'
- 'packages/erpc/Dockerfile'
- 'packages/ponder/**'
- name: "π§ Set up environment variables"
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "STAGE=production" >> $GITHUB_ENV
echo "PONDER_PROD_IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV
echo "PONDER_DEV_IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "STAGE=dev" >> $GITHUB_ENV
echo "PONDER_PROD_IMAGE_TAG=latest" >> $GITHUB_ENV
echo "PONDER_DEV_IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: "π¨ Install dependencies"
run: bun install --frozen-lockfile
- name: "π₯ Configure AWS Credentials"
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::262732185023:role/github-action-deploy-role
aws-region: eu-west-1
retry-max-attempts: 5
- name: "π₯ Login to Amazon ECR"
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up QEMU
if: steps.changes.outputs.dockerImage == 'true'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: steps.changes.outputs.dockerImage == 'true'
uses: docker/setup-buildx-action@v3
- name: "π¨ Build Ponder dev docker dependencies"
if: steps.changes.outputs.ponder == 'true' && env.STAGE == 'dev'
uses: docker/build-push-action@v6
with:
context: ./packages/ponder
platforms: linux/arm64
push: true
tags: |
262732185023.dkr.ecr.eu-west-1.amazonaws.com/indexer-dev:latest
262732185023.dkr.ecr.eu-west-1.amazonaws.com/indexer-dev:${{ github.sha }}
# Github actions cache
cache-from: type=gha
cache-to: type=gha,mode=min
- name: "π¨ Build Ponder prod docker dependencies"
if: steps.changes.outputs.ponder == 'true' && env.STAGE == 'production'
uses: docker/build-push-action@v6
with:
context: ./packages/ponder
platforms: linux/arm64
push: true
tags: |
262732185023.dkr.ecr.eu-west-1.amazonaws.com/indexer-prod:latest
262732185023.dkr.ecr.eu-west-1.amazonaws.com/indexer-prod:${{ github.sha }}
# Github actions cache
cache-from: type=gha
cache-to: type=gha,mode=min
- name: "π¨ Build ERPC docker dependencies"
if: steps.changes.outputs.erpc == 'true' && env.STAGE == 'production'
uses: docker/build-push-action@v6
with:
context: ./packages/erpc
platforms: linux/arm64
push: true
tags: |
262732185023.dkr.ecr.eu-west-1.amazonaws.com/erpc:latest
262732185023.dkr.ecr.eu-west-1.amazonaws.com/erpc:${{ github.sha }}
# Github actions cache
cache-from: type=gha
cache-to: type=gha,mode=min
no-cache: true
- name: "π SST Deploy"
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
bun run deploy:prod
else
bun run deploy:dev
fi
env:
ERPC_IMAGE_TAG: ${{ steps.changes.outputs.erpc == 'true' && github.sha || 'latest' }}
PONDER_DEV_IMAGE_TAG: ${{ steps.changes.outputs.ponder == 'true' && env.PONDER_DEV_IMAGE_TAG || 'latest' }}
PONDER_PROD_IMAGE_TAG: ${{ steps.changes.outputs.ponder == 'true' && env.PONDER_PROD_IMAGE_TAG || 'latest' }}