-
Notifications
You must be signed in to change notification settings - Fork 170
196 lines (160 loc) · 6.13 KB
/
ci-cd-pipeline.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: CI/CD pipeline
env:
DOCKER_REGISTRY: nethermind.jfrog.io
REPO_DEV: nubia-oci-local-dev
REPO_STAGING: nubia-oci-local-staging
REPO_PROD: nubia-oci-local-prod
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: write
jobs:
build_docker_image:
runs-on: ubuntu-latest
outputs:
DOCKER_IMAGE_TAG: ${{ steps.set_tag.outputs.DOCKER_IMAGE_TAG }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Define image tag
id: set_tag
run: |
export DOCKER_IMAGE_TAG=$(git describe --tags)
# This one is to be able to use the image tag in the next steps in this job
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG" >> $GITHUB_ENV
# This one is to be able to use the image tag in the next jobs
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to registry
run: |
docker login ${{ env.DOCKER_REGISTRY }} -u ${{ secrets.ARTIFACTORY_NUBIA_USERNAME }} -p ${{ secrets.ARTIFACTORY_NUBIA_TOKEN_DEVELOPER }}
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: .
platforms: "linux/amd64"
push: true
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.REPO_DEV }}/juno:${{ env.DOCKER_IMAGE_TAG }}
${{ env.DOCKER_REGISTRY }}/${{ env.REPO_DEV }}/juno:latest
validate_dev:
permissions:
id-token: write
contents: write
needs: [build_docker_image]
runs-on: ubuntu-latest
environment:
name: Development
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Verify Deployment Version (Dev)
run: |
bash .github/workflow-scripts/verify_deployment.sh ${{ secrets.DEV_SEPOLIA_URL }} ${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
dev-starknet-rs-tests:
needs: [validate_dev]
uses: ./.github/workflows/starknet-rs-tests.yml
secrets:
STARKNET_RPC: ${{ secrets.DEV_SEPOLIA_URL }}/v0_7
dev-starknet-js-tests:
needs: [validate_dev]
uses: ./.github/workflows/starknet-js-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.DEV_SEPOLIA_URL }}/v0_7
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}
dev-starknet-go-tests:
needs: [validate_dev]
uses: ./.github/workflows/starknet-go-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.DEV_SEPOLIA_URL }}/v0_7
promote_to_staging:
needs: [build_docker_image, validate_dev]
runs-on: ubuntu-latest
environment:
name: Staging
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup oras cli
uses: oras-project/setup-oras@v1
- name: Login to registry
run: |
oras login ${{ env.DOCKER_REGISTRY }} -u ${{ secrets.ARTIFACTORY_NUBIA_USERNAME }} -p ${{ secrets.ARTIFACTORY_NUBIA_TOKEN_DEVELOPER }}
- name: Promote to Staging
run: |
OLD_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_DEV }}/juno:${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
NEW_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_STAGING }}/juno:${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
oras cp -r $OLD_TAG $NEW_TAG,latest
- name: Verify Deployment Version (Staging)
run: |
bash .github/workflow-scripts/verify_deployment.sh ${{ secrets.STAGING_SEPOLIA_URL }} ${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
staging-starknet-rs-tests:
needs: [promote_to_staging]
uses: ./.github/workflows/starknet-rs-tests.yml
secrets:
STARKNET_RPC: ${{ secrets.STAGING_SEPOLIA_URL }}/v0_7
staging-starknet-js-tests:
needs: [promote_to_staging]
uses: ./.github/workflows/starknet-js-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.STAGING_SEPOLIA_URL }}/v0_7
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}
staging-starknet-go-tests:
needs: [promote_to_staging]
uses: ./.github/workflows/starknet-go-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.STAGING_SEPOLIA_URL }}/v0_7
promote_to_production:
needs: [build_docker_image, promote_to_staging]
runs-on: ubuntu-latest
environment:
name: Production
steps:
- name: Setup oras cli
uses: oras-project/setup-oras@v1
- name: Login to registry
run: |
oras login ${{ env.DOCKER_REGISTRY }} -u ${{ secrets.ARTIFACTORY_NUBIA_USERNAME }} -p ${{ secrets.ARTIFACTORY_NUBIA_TOKEN_DEVELOPER }}
- name: Promote to Production
run: |
OLD_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_STAGING }}/juno:${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
NEW_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_PROD }}/juno:${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
oras cp -r $OLD_TAG $NEW_TAG,latest
test_in_production:
needs: [promote_to_production]
runs-on: ubuntu-latest
environment:
name: ProductionTests # Artificial gate to enforce manual approval
steps:
- name: Starting production tests
run: |
echo "Tests in production will start shortly."
prod-starknet-rs-tests:
needs: [test_in_production]
uses: ./.github/workflows/starknet-rs-tests.yml
secrets:
STARKNET_RPC: ${{ secrets.PROD_SEPOLIA_URL }}/v0_7
prod-starknet-js-tests:
needs: [test_in_production]
uses: ./.github/workflows/starknet-js-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.PROD_SEPOLIA_URL }}/v0_7
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}
prod-starknet-go-tests:
needs: [test_in_production]
uses: ./.github/workflows/starknet-go-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.PROD_SEPOLIA_URL }}/v0_7