-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 2.22 KB
/
cd.yaml
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
name: Deploy [prod]
on:
push:
branches:
- "main"
paths-ignore:
- 'README.md'
- 'docs/**'
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER_NAME }}
ENV_PROD: ${{ secrets.ENV_PROD }}
GKE_ZONE: us-central1-c
IMAGE: api-cct
MY_ENV: production
jobs:
lint:
name: Dockerfiles linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run hadolint
uses: reviewdog/action-hadolint@v1
with:
hadolint_ignore: DL3008
reporter: github-pr-review
build:
needs: [lint]
name: Build and update deployments
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Google Cloud CLI
uses: google-github-actions/setup-gcloud@v0.2.1
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
- name: Configure Docker with gcloud
run: |-
gcloud --quiet auth configure-docker
- name: Get GKE credentials
uses: google-github-actions/get-gke-credentials@v0.2.1
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Mount env
run: |-
echo "${{ secrets.ENV_PROD }}" > env-deploy
ls -a
- name: Build Docker image
run: |-
pwd
ls -a
docker build \
--tag "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" \
-f Dockerfile \
.
- name: Publish Docker image
run: |-
docker push "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA"
- name: Set up Kustomize
run: |-
cd ./.kubernetes/prod
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
- name: Deploy
run: |-
cd ./.kubernetes/prod
./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA
./kustomize build . | kubectl apply -n cct -f -
kubectl get services -n cct -o wide
# trigger