-
Notifications
You must be signed in to change notification settings - Fork 826
86 lines (72 loc) · 3.1 KB
/
deploy-web-dev-cn.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
name: Deploy Flat Web Dev
on:
push:
branches:
- "main"
- "only-deploy-dev-web"
jobs:
deploy-flat-web-dev:
environment: development
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: Restore Cache
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- 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 development
run: pnpm -F flat-web build:cn -m development
- 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
env:
COMMIT_SHA_TAG: development-${{ github.sha }}
LATEST_DEV_TAG: dev-latest
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/flat-web:$COMMIT_SHA_TAG -t agoraflat/flat-web:$LATEST_DEV_TAG -t $PRIVATE_DOCKERHUB_REGISTRY/agoraflat/flat-web:$COMMIT_SHA_TAG -t $PRIVATE_DOCKERHUB_REGISTRY/agoraflat/flat-web:$LATEST_DEV_TAG
docker push agoraflat/flat-web:$COMMIT_SHA_TAG
docker push agoraflat/flat-web:$LATEST_DEV_TAG
docker login -u $PRIVATE_DOCKERHUB_USERNAME -p $PRIVATE_DOCKERHUB_PASSWORD $PRIVATE_DOCKERHUB_REGISTRY
docker push $PRIVATE_DOCKERHUB_REGISTRY/agoraflat/flat-web:$COMMIT_SHA_TAG
docker push $PRIVATE_DOCKERHUB_REGISTRY/agoraflat/flat-web:$LATEST_DEV_TAG
- name: Prep helm chart
env:
DOCKER_IMAGE_NAME: ${{ secrets.PRIVATE_DOCKERHUB_REGISTRY }}/agoraflat/flat-web
DOCKER_IMAGE_TAG: development-${{ github.sha }}
run: |
export APPVERSION=development-${{ 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
uses: WyriHaximus/github-action-helm3@v2
with:
exec: helm upgrade flat-web ./web/flat-web/helm --install --wait --atomic --namespace=default --set replicaCount=2
kubeconfig: "${{ secrets.KUBECONFIG }}"