forked from google-github-actions/deploy-cloudrun
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (147 loc) · 5.28 KB
/
deploy-cloudrun-it.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: deploy-cloudrun Integration
on: [push]
jobs:
envvars:
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
name: with Env Vars
runs-on: ubuntu-latest
steps:
- id: service
run: echo ::set-output name=service::run-envvars-$GITHUB_SHA
- uses: actions/checkout@v2
- uses: actions/setup-node@master
with:
node-version: 12.x
- name: Build Javascript
run: |-
npm install
npm run build
- name: Create Service with one env var
id: deploy_1
uses: ./
with:
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
image: gcr.io/cloudrun/hello
service: ${{ steps.service.outputs.service }}
env_vars: TEST_ENV=TEST_VAR
- name: Setup Authentication with gcloud
uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
export_default_credentials: true
- name: Integration Tests
run: npm run e2e-tests
env:
URL: ${{ steps.deploy_1.outputs.url }}
SERVICE: ${{ steps.service.outputs.service }}
ENV: TEST_ENV=TEST_VAR
- name: Update Service with second env var
id: deploy_2
uses: ./
with:
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
image: gcr.io/cloudrun/hello
service: ${{ steps.service.outputs.service }}
env_vars: TEST_ENV2=TEST_VAR2
- name: Integration Tests # Check that config isn't overwritten
run: npm run e2e-tests
env:
URL: ${{ steps.deploy_2.outputs.url }}
SERVICE: ${{ steps.service.outputs.service }}
ENV: TEST_ENV=TEST_VAR,TEST_ENV2=TEST_VAR2
yaml:
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
name: with YAML metadata
runs-on: ubuntu-latest
steps:
- id: service
run: echo ::set-output name=service::run-yaml-$GITHUB_SHA
- uses: actions/checkout@v2
- uses: actions/setup-node@master
with:
node-version: 12.x
- name: Build Javascript
run: |-
npm install
npm run build
- name: Deploy Service
id: deploy
uses: ./
with:
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
service: ${{ steps.service.outputs.service }}
metadata: ./tests/unit/service.basic.yaml
- name: Setup Authentication with gcloud
uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
export_default_credentials: true
- name: Integration Tests
run: npm run e2e-tests
env:
URL: ${{ steps.deploy.outputs.url }}
metadata:
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
name: with full YAML metada
runs-on: ubuntu-latest
steps:
- id: service
run: echo ::set-output name=service::run-full-yaml-$GITHUB_SHA
- uses: actions/checkout@v2
- uses: actions/setup-node@master
with:
node-version: 12.x
- name: Build Javascript
run: |-
npm install
npm run build
- name: Create service from metadata yaml
id: deploy_1
uses: ./
with:
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
service: ${{ steps.service.outputs.service }}
metadata: ./tests/unit/service.full.yaml
- name: Setup Authentication with gcloud
uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
export_default_credentials: true
- name: Integration Tests
run: npm run e2e-tests
env:
URL: ${{ steps.deploy_1.outputs.url }}
PARAMS: "{\"cpu\": 2,\"memory\": \"1Gi\", \"containerConcurrency\": 20}"
ANNOTATIONS: "{\"run.googleapis.com/cloudsql-instances\": \"1:2:3\"}"
LABELS: "{\"test_label\": \"test_value\"}"
- name: Update service with new image
id: deploy_2
uses: ./
with:
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
image: gcr.io/cloudrun/hello
service: ${{ steps.service.outputs.service }}
- name: Integration Tests # Check that config isn't overwritten
run: npm run e2e-tests
env:
URL: ${{ steps.deploy_2.outputs.url }}
SERVICE: ${{ steps.service.outputs.service }}
PARAMS: "{\"cpu\": 2,\"memory\": \"1Gi\", \"containerConcurrency\": 20}"
ANNOTATIONS: "{\"run.googleapis.com/cloudsql-instances\": \"1:2:3\"}"
LABELS: "{\"test_label\": \"test_value\"}"
cleanup:
name: Clean Up
runs-on: ubuntu-latest
needs: [envvars, metadata, yaml]
steps:
- uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
project_id: ${{ secrets.DEPLOY_CLOUDRUN_PROJECT_ID }}
- name: Delete services
run: |-
gcloud config set run/platform managed
gcloud config set run/region us-central1
gcloud run services delete run-full-yaml-$GITHUB_SHA --quiet
gcloud run services delete run-yaml-$GITHUB_SHA --quiet
gcloud run services delete run-envvars-$GITHUB_SHA --quiet