-
Notifications
You must be signed in to change notification settings - Fork 5
executable file
·85 lines (78 loc) · 2.77 KB
/
gke-preview.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
name: Build and Deploy to GKE Preview
on:
workflow_dispatch:
push:
branches:
- cicd
- preview
release:
types: [prereleased]
# Environment variables available to all jobs and steps in this workflow
env:
REGISTRY_HOSTNAME: gcr.io
GKE_PROJECT: console-labs-prod
IMAGE: consolelabs/mochi-web
K8S_ENVIRONMENT: preview
SHA: ${{ github.sha }}
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
environment: Preview – websites-mochi
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GCR
uses: docker/login-action@v3
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCP_CREDENTIALS }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ env.REGISTRY_HOSTNAME }}/${{ env.GKE_PROJECT }}/${{ env.IMAGE }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=,suffix=,format=long
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
build-args: |
NEXT_PUBLIC_MOCHI_PROFILE_API_HOST=${{ secrets.NEXT_PUBLIC_MOCHI_PROFILE_API_HOST }}
NEXT_PUBLIC_MOCHI_API_HOST=${{ secrets.NEXT_PUBLIC_MOCHI_API_HOST }}
NEXT_PUBLIC_MOCHI_PAY_API_HOST=${{ secrets.NEXT_PUBLIC_MOCHI_PAY_API_HOST }}
# Setup kustomize
- uses: imranismail/setup-kustomize@v2
with:
kustomize-version: "5.1.1"
github-token: ${{ secrets.GH_PAT }}
# Update app version
- name: Checkout consolelabs/infrastructure
uses: actions/checkout@master
with:
repository: consolelabs/infrastructure
token: ${{ secrets.GH_PAT }}
path: ./infrastructure
ref: main
- name: Update app version
run: |
cd ./infrastructure/mochi-web/$K8S_ENVIRONMENT
git config user.name lmquang
git config user.email quanglm.ops@gmail.com
kustomize edit set image $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE=$REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${SHA}
git commit -am "[skip ci] mochi-web ${K8S_ENVIRONMENT} image update"
git push origin main