forked from debionetwork/debio-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (184 loc) · 7.72 KB
/
beta.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
name: Beta automation
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+-beta*'
concurrency:
group: beta-automation
jobs:
compute-build-info:
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.build-info.outputs.latest_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Compute build info
id: build-info
shell: bash
run: |
version=${GITHUB_REF#refs/*/}
echo $version
echo "::set-output name=latest_tag::$version"
build-and-publish-docker-image:
runs-on: ubuntu-latest
needs: compute-build-info
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.TESTNET_GCP_PROJECT_ID }}
service_account_key: ${{ secrets.TESTNET_GCP_SA_KEY }}
export_default_credentials: true
- name: Get secrets
id: secrets
uses: google-github-actions/get-secretmanager-secrets@main
with:
secrets: |-
VUE_APP_RECAPTCHA_SITE_KEY:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_RECAPTCHA_SITE_KEY
VUE_APP_ROLE:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_ROLE
VUE_APP_DEBIO_USE_TOKEN_NAME:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_DEBIO_USE_TOKEN_NAME
VUE_APP_DEBIO_ESCROW_ETH_ADDRESS:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_DEBIO_ESCROW_ETH_ADDRESS
VUE_APP_DEBIO_SUBSTRATE_WS:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_DEBIO_SUBSTRATE_WS
VUE_APP_WEB3_RPC:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_WEB3_RPC
VUE_APP_BACKEND_API:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_BACKEND_API
VUE_APP_DEBIO_API_KEY:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_DEBIO_API_KEY
VUE_APP_USERNAME:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_USERNAME
VUE_APP_PASSWORD:${{ secrets.TESTNET_GCP_PROJECT_ID }}/VUE_APP_PASSWORD
LABS_JS:${{ secrets.TESTNET_GCP_PROJECT_ID }}/LABS_JS
- name: Create .env & gcp sa
shell: bash
run: |
tee -a .env <<EOF
VUE_APP_RECAPTCHA_SITE_KEY=${{ steps.secrets.outputs.VUE_APP_RECAPTCHA_SITE_KEY }}
VUE_APP_ROLE=${{ steps.secrets.outputs.VUE_APP_ROLE }}
VUE_APP_DEBIO_USE_TOKEN_NAME=${{ steps.secrets.outputs.VUE_APP_DEBIO_USE_TOKEN_NAME }}
VUE_APP_DEBIO_ESCROW_ETH_ADDRESS=${{ steps.secrets.outputs.VUE_APP_DEBIO_ESCROW_ETH_ADDRESS }}
VUE_APP_DEBIO_SUBSTRATE_WS=${{ steps.secrets.outputs.VUE_APP_DEBIO_SUBSTRATE_WS }}
VUE_APP_WEB3_RPC=${{ steps.secrets.outputs.VUE_APP_WEB3_RPC }}
VUE_APP_BACKEND_API=${{ steps.secrets.outputs.VUE_APP_BACKEND_API }}
VUE_APP_DEBIO_API_KEY=${{ steps.secrets.outputs.VUE_APP_DEBIO_API_KEY }}
VUE_APP_USERNAME=${{ steps.secrets.outputs.VUE_APP_USERNAME }}
VUE_APP_PASSWORD=${{ steps.secrets.outputs.VUE_APP_PASSWORD }}
EOF
tee -a ./src/views/Login/DemoLabAccounts/labs.js <<EOF
${{ steps.secrets.outputs.LABS_JS }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-main
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
id: docker_build
with:
context: .
push: true
file: .maintain/docker/Dockerfile
tags: |
${{ github.repository }}:${{ needs.compute-build-info.outputs.latest_tag }}
${{ github.repository }}:latest-beta
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
publish-draft-release:
runs-on: ubuntu-latest
needs: [build-and-publish-docker-image]
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
configuration: '.github/workflows/rcb_config.json'
- name: Create draft release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.build_changelog.outputs.changelog }}
draft: true
prerelease: true
deploy:
runs-on: ubuntu-latest
needs: [compute-build-info, publish-draft-release]
env:
DEPLOY: ${{ secrets.TESTNET_DEPLOY }}
steps:
- name: Checkout code
if: "${{ env.DEPLOY == 'true' }}"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Cloud SDK
if: "${{ env.DEPLOY == 'true' }}"
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.TESTNET_GCP_PROJECT_ID }}
service_account_key: ${{ secrets.TESTNET_GCP_SA_KEY }}
export_default_credentials: true
- name: Get secrets
if: "${{ env.DEPLOY == 'true' }}"
id: secrets
uses: google-github-actions/get-secretmanager-secrets@main
with:
secrets: |-
SSH_HOST:${{ secrets.TESTNET_GCP_PROJECT_ID }}/SSH_HOST
SSH_USERNAME:${{ secrets.TESTNET_GCP_PROJECT_ID }}/SSH_USERNAME
SSH_KEY:${{ secrets.TESTNET_GCP_PROJECT_ID }}/SSH_KEY
SSH_PORT:${{ secrets.TESTNET_GCP_PROJECT_ID }}/SSH_PORT
- name: Deploy
if: "${{ env.DEPLOY == 'true' }}"
uses: appleboy/ssh-action@master
with:
host: ${{ steps.secrets.outputs.SSH_HOST }}
username: ${{ steps.secrets.outputs.SSH_USERNAME }}
key: ${{ steps.secrets.outputs.SSH_KEY }}
port: ${{ steps.secrets.outputs.SSH_PORT }}
script: |
./connect.sh
helm repo add debio https://charts.debio.network
helm repo update
helm upgrade debio-frontend debio/debio-frontend \
--install \
--set-string image.tag=${{ needs.compute-build-info.outputs.latest_tag }} \
--set-string image.pullPolicy=Always \
--set ingress.enabled=true \
--set-string ingress.annotations."kubernetes\.io/ingress\.class"=nginx \
--set-string ingress.annotations."cert-manager\.io/cluster-issuer"=letsencrypt \
--set-string ingress.annotations."nginx\.ingress\.kubernetes\.io/limit-rps"="100" \
--set-string ingress.hosts[0].host=lab.testnet.debio.network \
--set-string ingress.hosts[0].paths[0].path=/ \
--set-string ingress.hosts[0].paths[0].pathType=ImplementationSpecific \
--set-string ingress.tls[0].secretName=debio-frontend-tls \
--set-string ingress.tls[0].hosts[0]=lab.testnet.debio.network \
--set autoscaling.enabled=true
kubectl rollout status deployment/debio-frontend