-
Notifications
You must be signed in to change notification settings - Fork 66
151 lines (132 loc) · 5.75 KB
/
deploy-testnet.yml
File metadata and controls
151 lines (132 loc) · 5.75 KB
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
name: Deploy to Testnet
on:
release:
types: [prereleased]
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
jobs:
deploy-testnet:
name: Deploy new aleph-node image to Testnet EKS
runs-on: ubuntu-20.04
environment:
name: testnet
env:
AWS_REGION: us-east-1 # this region is used by all public ECR repos
steps:
- name: GIT | Checkout
uses: actions/checkout@v2
- name: GIT | Get branch info & current commit sha.
id: vars
shell: bash
run: |
echo "branch=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Public Amazon ECR
id: login-public-ecr
uses: docker/login-action@v1
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }}
- name: Tag and push image for Testnet
env:
DEVNET_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.sha_short }}
TESTNET_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.branch }}
run: |
export image_not_exist=$(docker manifest inspect ${{ env.DEVNET_IMAGE }} &> /dev/null ; echo $?)
if [ $image_not_exist -eq 1 ]; then
echo "::error title=Wrong docker image tag::Docker image ${{ env.DEVNET_IMAGE }} doesn't exist"
exit 1
else
docker pull ${{ env.DEVNET_IMAGE }}
docker tag ${{ env.DEVNET_IMAGE }} ${{ env.TESTNET_IMAGE }}
docker push ${{ env.TESTNET_IMAGE }}
fi
- name: Login to Docker Hub
id: login-docker-hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Tag and push image of Testnet to DockerHub
env:
TESTNET_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.branch }}
DOCKERHUB_TESTNET_IMAGE: cardinalcryptography/aleph-zero:testnet-${{ steps.vars.outputs.branch }}
DOCKERHUB_TESTNET_LATEST_IMAGE: cardinalcryptography/aleph-zero:testnet-latest
run: |
echo "FROM ${{ env.TESTNET_IMAGE }}" > Dockerfile.dockerhub
echo 'ENTRYPOINT ["/usr/local/bin/aleph-node"]' >> Dockerfile.dockerhub
docker build -t ${{ env.DOCKERHUB_TESTNET_IMAGE }} -f Dockerfile.dockerhub .
docker tag ${{ env.DOCKERHUB_TESTNET_IMAGE }} ${{ env.DOCKERHUB_TESTNET_LATEST_IMAGE }}
docker push ${{ env.DOCKERHUB_TESTNET_IMAGE }}
docker push ${{ env.DOCKERHUB_TESTNET_LATEST_IMAGE }}
- name: S3 CI | Download release runtime from S3 bucket
shell: bash
env:
S3BUCKET_URL: s3://${{ secrets.CI_MAINNET_S3BUCKET_NAME }}/builds/aleph-node/commits/${{ steps.vars.outputs.sha_short }}/aleph-runtime
S3BUCKET_FILE: aleph-runtime-${{ steps.vars.outputs.sha_short }}.tar.gz
run: |
aws s3 cp ${{ env.S3BUCKET_URL }}/${{ env.S3BUCKET_FILE }} ${{ env.S3BUCKET_FILE }}
- name: RELEASE ASSET | Add runtime to the release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
aleph-runtime-${{ steps.vars.outputs.sha_short }}.tar.gz
- name: GIT | Checkout aleph-apps repo
uses: actions/checkout@master
with:
ref: testnet
repository: Cardinal-Cryptography/aleph-apps
token: ${{ secrets.CI_GH_TOKEN }}
path: "aleph-apps"
- name: Init kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: "3.8.6"
- name: Update aleph-node docker image and trigger ArgoCD deploy for Testnet
env:
TESTNET_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.branch }}
REGIONS_AWS: 'eu-central-1,eu-west-1,eu-west-2,us-east-1,us-east-2'
run: |
IFS="," read -a region_array <<< ${{ env.REGIONS_AWS }}
export aleph_path=$(pwd)
for i in "${region_array[@]}"; do
# Deploy new image version for archivist
cd ${aleph_path}/aleph-apps/aleph-node-archivists/overlays/testnet/${i}
kustomize edit set image "aleph-node-archivist-image-placeholder=${{ env.TESTNET_IMAGE }}"
# Deploy new image version for validator
cd ${aleph_path}/aleph-apps/aleph-node-validators/overlays/testnet/${i}
kustomize edit set image "aleph-node-validator-image-placeholder=${{ env.TESTNET_IMAGE }}"
done
- name: GIT | Commit changes to aleph-apps repository.
uses: EndBug/add-and-commit@v5.1.0
with:
author_name: AlephZero Automation
author_email: alephzero@10clouds.com
message: "Updating Testnet docker image tag for pre-release: ${{ steps.vars.outputs.branch }}"
add: "*.yaml"
cwd: "aleph-apps"
branch: testnet
env:
GITHUB_TOKEN: ${{ secrets.CI_GH_TOKEN }}
slack:
name: Slack notification
runs-on: ubuntu-20.04
needs: [deploy-testnet]
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Send Slack message
uses: ./.github/actions/slack-notification
with:
notify-on: "failure"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}