-
Notifications
You must be signed in to change notification settings - Fork 826
81 lines (68 loc) · 3.03 KB
/
deploy-web-prod-sg.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
name: Deploy Flat Web Prod
on:
push:
branches:
- "stable"
- "only-deploy-prod-web"
jobs:
deploy-flat-web-prod-sg:
environment: production
env:
FLAT_UA: ${{ secrets.FLAT_UA }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install PNPM
uses: pnpm/action-setup@v2
with:
version: latest
- name: Install dependencies
run: |
node ./scripts/ci/remove-workspace-packages.js web
node ./scripts/ci/remove-package-scripts-hooks.js
# failure automatically retries 3 times
pnpm i || pnpm i || pnpm i
- name: Build flat web production
run: pnpm -F flat-web build:sg -m production
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Reset dockerignore
run: |
echo "*" > .dockerignore
echo "!web/flat-web/dist" >> .dockerignore
echo "!web/flat-web/deploy/nginx" >> .dockerignore
- name: Build and push images production
env:
COMMIT_SHA_TAG: production-${{ github.sha }}
LATEST_PROD_TAG: latest
IMAGE_NAME: flat-web-sg
PRIVATE_DOCKERHUB_REGISTRY: ${{ secrets.PRIVATE_DOCKERHUB_REGISTRY }}
PRIVATE_DOCKERHUB_USERNAME: ${{ secrets.PRIVATE_DOCKERHUB_USERNAME }}
PRIVATE_DOCKERHUB_PASSWORD: ${{ secrets.PRIVATE_DOCKERHUB_PASSWORD }}
run: |
docker build . -f web/flat-web/deploy/Dockerfile -t agoraflat/$IMAGE_NAME:$COMMIT_SHA_TAG -t agoraflat/$IMAGE_NAME:$LATEST_PROD_TAG -t $PRIVATE_DOCKERHUB_REGISTRY/agoraflat/$IMAGE_NAME:$COMMIT_SHA_TAG -t $PRIVATE_DOCKERHUB_REGISTRY/agoraflat/$IMAGE_NAME:$LATEST_PROD_TAG
docker push agoraflat/$IMAGE_NAME:$COMMIT_SHA_TAG
docker push agoraflat/$IMAGE_NAME:$LATEST_PROD_TAG
docker login -u $PRIVATE_DOCKERHUB_USERNAME -p $PRIVATE_DOCKERHUB_PASSWORD $PRIVATE_DOCKERHUB_REGISTRY
docker push $PRIVATE_DOCKERHUB_REGISTRY/agoraflat/$IMAGE_NAME:$COMMIT_SHA_TAG
docker push $PRIVATE_DOCKERHUB_REGISTRY/agoraflat/$IMAGE_NAME:$LATEST_PROD_TAG
- name: Prep helm chart
env:
DOCKER_IMAGE_NAME: ${{ secrets.PRIVATE_DOCKERHUB_REGISTRY }}/agoraflat/flat-web-sg
DOCKER_IMAGE_TAG: production-${{ github.sha }}
run: |
export APPVERSION=production-${{ github.sha }}
export CHART=./web/flat-web/helm/Chart.yaml
sed -i "s/^appVersion:.*$/appVersion: $APPVERSION/" $CHART
export VALUE=./web/flat-web/helm/values.yaml
sed -i "s|DOCKER_IMAGE_NAME|$DOCKER_IMAGE_NAME|" $VALUE
sed -i "s|DOCKER_IMAGE_TAG|$DOCKER_IMAGE_TAG|" $VALUE
- name: Deploy SG
uses: WyriHaximus/github-action-helm3@v2
with:
exec: helm upgrade flat-web ./web/flat-web/helm --install --wait --atomic --namespace=default
kubeconfig: "${{ secrets.KUBECONFIG_SG }}"