-
-
Notifications
You must be signed in to change notification settings - Fork 9
67 lines (56 loc) · 1.83 KB
/
production.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
name: master
on:
push:
branches:
- "master"
env:
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
GKE_ZONE: ${{ secrets.GKE_ZONE }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
CLUSTER: stoqey
DEPLOYMENT: dior
IMAGE: dior
jobs:
setup-build-publish-deploy:
name: deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Setup gcloud CLI
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '290.0.1'
service_account_key: ${{ secrets.GKE_SA_KEY }}
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- name: Save docker configure
run: |-
gcloud --quiet auth configure-docker
# Build the Docker image
- name: Build image
run: |-
docker build \
--tag "gcr.io/$GKE_PROJECT/$IMAGE:${GITHUB_SHA:0:7}" \
--build-arg GITHUB_SHA="$GITHUB_SHA" \
--build-arg GITHUB_REF="$GITHUB_REF" \
.
# Push the Docker image to Google Container Registry
- name: Push image to GCR
run: |-
docker push "gcr.io/$GKE_PROJECT/$IMAGE:${GITHUB_SHA:0:7}"
# Setup DigitalOcean
- name: Setup DigitalOcean doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
# Set up k8s
- name: Set up k8s
run: sudo snap install kubectl --classic
# Get the cluster credentials so we can deploy to the cluster
- name: Save k8s kubeconfig
run: doctl kubernetes cluster kubeconfig save "$CLUSTER"
# Deploy the Docker image to the GKE cluster
- name: Deploy to k8s
run: kubectl set image deployment/$DEPLOYMENT $DEPLOYMENT=gcr.io/$GKE_PROJECT/$IMAGE:${GITHUB_SHA:0:7}