-
Notifications
You must be signed in to change notification settings - Fork 7
112 lines (92 loc) · 3.01 KB
/
deploy-staging.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
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
name: Deploy Staging
on:
push:
branches:
- master
jobs:
build:
name: Build Images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Gcloud Auth
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.ORG_SANDBOX_DEPLOYMENT_KEY }}"
- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Set Image Tag
id: lookup
run: echo "version=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- run: |
gcloud auth list
gcloud auth configure-docker -q
echo "VERSION: ${{ steps.lookup.outputs.version }}"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: Cache Docker Layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-website-cache
key: ${{ runner.os }}-buildx-image-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-image
- name: Build and Push Images
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: gcr.io/fetch-ai-sandbox/docs-website:${{ steps.lookup.outputs.version }}
cache-from: type=local,src=/tmp/.buildx-website-cache
cache-to: type=local,dest=/tmp/.buildx-website-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-website-cache
mv /tmp/.buildx-website-cache-new /tmp/.buildx-website-cache
deploy:
name: Deployment
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Gcloud Auth
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.ORG_SANDBOX_DEPLOYMENT_KEY }}"
- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Set Image Tag
id: lookup
run: echo "version=$(git describe --always --dirty=-wip)" >> $GITHUB_OUTPUT
- name: Turnstyle
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to Staging
env:
IMAGE_TAG: ${{ steps.lookup.outputs.version }}
HELM_NAME: staging
NAMESPACE: docs-staging
GKE_PROJECT: fetch-ai-sandbox
GKE_CLUSTER: london-b
GKE_ZONE: europe-west2-b
run: |
gcloud components install gke-gcloud-auth-plugin
gcloud container clusters get-credentials $GKE_CLUSTER \
--zone $GKE_ZONE \
--project $GKE_PROJECT
helm upgrade --install --wait --timeout 300s $HELM_NAME \
./k8s/docs/ \
--set-string website.image.tag=$IMAGE_TAG \
-n $NAMESPACE