forked from idirall22/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (103 loc) · 4.86 KB
/
dev.yml
File metadata and controls
114 lines (103 loc) · 4.86 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
name: Dev
on:
push:
tags:
- 'dev'
# Environment variables available to all jobs and steps in this workflow
env:
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
GKE_EMAIL: ${{ secrets.GKE_EMAIL }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
GKE_ZONE: ${{ secrets.GKE_ZONE }}
GKE_KEYRING_ZONE: global
GKE_KEYRING_NAME: ${{ secrets.GKE_KEYRING_NAME }}
GKE_KEY_NAME: ${{ secrets.GKE_KEY_NAME }}
IMAGE: maintemplate
AUTHZ_IMAGE: ext-authz
REGISTRY_HOSTNAME: gcr.io
DEPLOYMENT_NAME: maintemplate
RELEASE_CHANNEL: dev
FLUTTER_CHANNEL: beta
CHANNEL_URL: getcouragenow.org
MINIO_ACCESSKEY: ${{ secrets.MINIO_ACCESSKEY }}
MINIO_SECRETKEY: ${{ secrets.MINIO_SECRETKEY }}
MINIO_LOCATION: ${{ secrets.MINIO_LOCATION }}
MINIO_TIMEOUT: ${{ secrets.MINIO_TIMEOUT }}
MINIO_ENCKEY: ${{ secrets.MINIO_ENCKEY }}
MINIO_SSL: ${{ secrets.MINIO_SSL }}
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: dev
- uses: subosito/flutter-action@v1
with:
channel: 'beta'
- run: flutter pub get
working-directory: maintemplate/client/
- run: flutter config --enable-web
working-directory: maintemplate/client/
# build Flutter web version
- run: flutter build web
working-directory: maintemplate/client/
# Setup gcloud CLI
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '285.0.0'
service_account_email: ${{ secrets.GKE_EMAIL }}
service_account_key: ${{ secrets.GKE_KEY }}
# Configure docker to use the gcloud command-line tool as a credential helper
- run: |
# Set up docker to authenticate
# via gcloud command-line tool.
gcloud auth configure-docker
# Create secret keys
- name: Create Secrets
run: |
make -C mod-account/server/authz/ gen-secrets -k
make -C maintemplate/server/ gen-app-secrets -k
kubectl apply -f keys/keypair-secrets.yaml
kubectl apply -f keys/minio-creds-secret.yaml
kubectl apply -f keys/getcourage-secrets.yaml
# Build the Docker image
- name: Build
run: |
docker build -t "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/"$AUTH_IMAGE":"$RELEASE_CHANNEL"-"$GITHUB_SHA" \
--build-arg GITHUB_SHA="$GITHUB_SHA"
--build-arg GITHUB_REF="$GITHUB_REF" -f mod-account/server/authz/Dockerfile .
docker build -t "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/"$IMAGE":"$RELEASE_CHANNEL"-"$GITHUB_SHA" \
--build-arg GITHUB_SHA="$GITHUB_SHA" \
--build-arg GITHUB_REF="$GITHUB_REF" -f maintemplate/server/Dockerfile .
sed -i s/\\?version\=#\{ref\}/?version=$GITHUB_SHA/g maintemplate/client/build/web/index.html
sed -i s/#\{channel_name\}/$RELEASE_CHANNEL/g maintemplate/client/build/web/assets/assets/env.json
sed -i s/#\{channel_url\}/$PROJECT.$RELEASE_CHANNEL.$URL/g maintemplate/client/build/web/assets/assets/env.json
sed -i s/#\{channel_url_native\}/grpc.$PROJECT.$RELEASE_CHANNEL.$URL/g maintemplate/client/build/web/assets/assets/env.json
sed -i s/#\{channel_githash\}/$GITHUB_SHA/g maintemplate/client/build/web/assets/assets/env.json
sed -i s/#\{flutter_channel\}/$FLUTTER_CHANNEL/g maintemplate/client/build/web/assets/assets/env.json
sed -i s/#\{locales\}/$LOCALES/g maintemplate/client/build/web/assets/assets/env.json
cp -rf maintemplate/client/build/web maintemplate/server/flutter
docker build -t "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/flutter-web-"$IMAGE":"$RELEASE_CHANNEL"-"$GITHUB_SHA" maintemplate/server/flutter
# Push the Docker image to Google Container Registry
- name: Publish
run: |
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${RELEASE_CHANNEL}-$GITHUB_SHA
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$AUTH_IMAGE:${RELEASE_CHANNEL}-$GITHUB_SHA
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/flutter-web-$IMAGE:${RELEASE_CHANNEL}-$GITHUB_SHA
# Set up helm v3
- name: Set up Helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 ./get_helm.sh
./get_helm.sh
# Deploy the Docker image to the GKE cluster
- name: Deploy
run: |
gcloud container clusters get-credentials $GKE_PROJECT --zone $GKE_ZONE --project $GKE_PROJECT
helm upgrade --force --install $RELEASE_CHANNEL ./maintemplate/server/deployments/helm\
--set flutterImage=gcr.io/$GKE_PROJECT/flutter-web-$IMAGE:${RELEASE_CHANNEL}-$GITHUB_SHA\
--set maintemplateServerImage=gcr.io/$GKE_PROJECT/$IMAGE:${RELEASE_CHANNEL}-$GITHUB_SHA\
${{ secrets.HELM_VARS }}