Skip to content

Commit 6928ef0

Browse files
authored
feat!: transfer Cloud Run action (#1)
* feat!: transfer Cloud Run action * run on push or correct PR
1 parent 1b5146f commit 6928ef0

24 files changed

+4271
-0
lines changed

.eslintrc.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the 'License');
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an 'AS IS' BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports = {
18+
root: true,
19+
parser: '@typescript-eslint/parser',
20+
plugins: ['@typescript-eslint'],
21+
extends: [
22+
'eslint:recommended',
23+
'plugin:@typescript-eslint/eslint-recommended',
24+
'plugin:@typescript-eslint/recommended',
25+
'plugin:prettier/recommended',
26+
'prettier/@typescript-eslint',
27+
],
28+
rules: {
29+
'@typescript-eslint/camelcase': 'off',
30+
'@typescript-eslint/no-non-null-assertion': 'off',
31+
}
32+
};

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Bug report
3+
about: Tell us about a bug.
4+
labels: bug
5+
---
6+
7+
### TL;DR
8+
<!-- Describe the bug in 1-2 sentences below. -->
9+
10+
**Expected behavior**
11+
<!-- What did you expect to happen? Please share below. -->
12+
13+
**Observed behavior**
14+
<!-- What did happened instead? Please share below. -->
15+
16+
17+
### Reproduction
18+
19+
**Action YAML**
20+
<!-- Add your complete GitHub Actions YAML below. -->
21+
22+
```yaml
23+
# Paste your complete GitHub Actions YAML here, removing
24+
# any sensitive values.
25+
```
26+
27+
**Repository**
28+
<!-- Is your repository public? If so, please link to it. -->
29+
<!-- If your repository is not public, delete this section. -->
30+
31+
32+
**Additional information**
33+
<!-- Are you running custom workers? Doing something atypical? Etc? -->

.github/ISSUE_TEMPLATE/feature.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Feature
3+
about: Request a new feature or functionality.
4+
labels: feature
5+
---
6+
7+
### TL;DR
8+
<!-- Describe the feature in 1-2 sentences below. -->
9+
10+
11+
### Design
12+
13+
**Action YAML**
14+
<!-- What do you envision the action to look like? -->
15+
<!-- If this is not relevant, delete this section. -->
16+
17+
```yaml
18+
# Paste your proposed GitHub Actions YAML here.
19+
```
20+
21+
**Resources**
22+
<!-- Please provide links to relevant documentation or examples. -->
23+
24+
- [Link to documentation](TODO)
25+
26+
27+
**Additional information**
28+
<!-- Are you running custom workers? Doing something atypical? Etc? -->

.github/ISSUE_TEMPLATE/question.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: Question
3+
about: Ask us a question.
4+
labels: question
5+
---
6+
7+
### Question
8+
<!-- Ask your question in 1-2 sentences below. -->
9+
<!-- If sharing code, please use ``` codeblocks -->
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: deploy-cloudrun credentials Integration
2+
3+
on: [push]
4+
5+
jobs:
6+
gcloud:
7+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
8+
name: with setup-gcloud
9+
runs-on: ubuntu-latest
10+
steps:
11+
- id: service
12+
run: echo ::set-output name=service::run-gcloud-$GITHUB_SHA
13+
- uses: actions/checkout@v2
14+
- uses: google-github-actions/setup-gcloud@master # Set up ADC to make authenticated request to service
15+
with:
16+
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
17+
export_default_credentials: true
18+
- uses: actions/setup-node@master
19+
with:
20+
node-version: 12.x
21+
- run: |-
22+
npm install
23+
npm run build
24+
- id: deploy
25+
uses: ./
26+
with:
27+
image: gcr.io/cloudrun/hello
28+
service: ${{ steps.service.outputs.service }}
29+
- name: Integration Tests
30+
run: npm run e2e-tests
31+
env:
32+
URL: ${{ steps.deploy.outputs.url }}
33+
34+
b64_json:
35+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
36+
name: with base64 json creds
37+
runs-on: ubuntu-latest
38+
steps:
39+
- id: service
40+
run: echo ::set-output name=service::run-b64-$GITHUB_SHA
41+
- uses: actions/checkout@v2
42+
- uses: actions/setup-node@master
43+
with:
44+
node-version: 12.x
45+
- run: |-
46+
npm install
47+
npm run build
48+
- id: deploy
49+
uses: ./
50+
with:
51+
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
52+
image: gcr.io/cloudrun/hello
53+
service: ${{ steps.service.outputs.service }}
54+
- uses: google-github-actions/setup-gcloud@master # Set up ADC to make authenticated request to service
55+
with:
56+
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
57+
export_default_credentials: true
58+
- name: Integration Tests
59+
run: npm run e2e-tests
60+
env:
61+
URL: ${{ steps.deploy.outputs.url }}
62+
63+
json:
64+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
65+
name: with json creds
66+
runs-on: ubuntu-latest
67+
steps:
68+
- id: service
69+
run: echo ::set-output name=service::run-json-$GITHUB_SHA
70+
- uses: actions/checkout@v2
71+
- uses: actions/setup-node@master
72+
with:
73+
node-version: 12.x
74+
- run: |-
75+
npm install
76+
npm run build
77+
- id: deploy
78+
uses: ./
79+
with:
80+
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
81+
image: gcr.io/cloudrun/hello
82+
service: ${{ steps.service.outputs.service }}
83+
- uses: google-github-actions/setup-gcloud@master # Set up ADC to make authenticated request to service
84+
with:
85+
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
86+
export_default_credentials: true
87+
- name: Integration Tests
88+
run: npm run e2e-tests
89+
env:
90+
URL: ${{ steps.deploy.outputs.url }}
91+
92+
cleanup:
93+
name: Clean Up
94+
runs-on: ubuntu-latest
95+
needs: [json, gcloud, b64_json]
96+
steps:
97+
- uses: google-github-actions/setup-gcloud@master
98+
with:
99+
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
100+
project_id: ${{ secrets.DEPLOY_CLOUDRUN_PROJECT_ID }}
101+
- name: Delete services
102+
run: |-
103+
gcloud config set run/platform managed
104+
gcloud config set run/region us-central1
105+
gcloud run services delete run-json-$GITHUB_SHA --quiet
106+
gcloud run services delete run-b64-$GITHUB_SHA --quiet
107+
gcloud run services delete run-gcloud-$GITHUB_SHA --quiet
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: deploy-cloudrun Integration
2+
3+
on: [push]
4+
5+
jobs:
6+
envvars:
7+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
8+
name: with Env Vars
9+
runs-on: ubuntu-latest
10+
steps:
11+
- id: service
12+
run: echo ::set-output name=service::run-envvars-$GITHUB_SHA
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@master
15+
with:
16+
node-version: 12.x
17+
- name: Build Javascript
18+
run: |-
19+
npm install
20+
npm run build
21+
- name: Create Service with one env var
22+
id: deploy_1
23+
uses: ./
24+
with:
25+
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
26+
image: gcr.io/cloudrun/hello
27+
service: ${{ steps.service.outputs.service }}
28+
env_vars: TEST_ENV=TEST_VAR
29+
- name: Setup Authentication with gcloud
30+
uses: google-github-actions/setup-gcloud@master
31+
with:
32+
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
33+
export_default_credentials: true
34+
- name: Integration Tests
35+
run: npm run e2e-tests
36+
env:
37+
URL: ${{ steps.deploy_1.outputs.url }}
38+
SERVICE: ${{ steps.service.outputs.service }}
39+
ENV: TEST_ENV=TEST_VAR
40+
- name: Update Service with second env var
41+
id: deploy_2
42+
uses: ./
43+
with:
44+
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
45+
image: gcr.io/cloudrun/hello
46+
service: ${{ steps.service.outputs.service }}
47+
env_vars: TEST_ENV2=TEST_VAR2
48+
- name: Integration Tests # Check that config isn't overwritten
49+
run: npm run e2e-tests
50+
env:
51+
URL: ${{ steps.deploy_2.outputs.url }}
52+
SERVICE: ${{ steps.service.outputs.service }}
53+
ENV: TEST_ENV=TEST_VAR,TEST_ENV2=TEST_VAR2
54+
55+
yaml:
56+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
57+
name: with YAML metadata
58+
runs-on: ubuntu-latest
59+
steps:
60+
- id: service
61+
run: echo ::set-output name=service::run-yaml-$GITHUB_SHA
62+
- uses: actions/checkout@v2
63+
- uses: actions/setup-node@master
64+
with:
65+
node-version: 12.x
66+
- name: Build Javascript
67+
run: |-
68+
npm install
69+
npm run build
70+
- name: Deploy Service
71+
id: deploy
72+
uses: ./
73+
with:
74+
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
75+
service: ${{ steps.service.outputs.service }}
76+
metadata: ./tests/unit/service.basic.yaml
77+
- name: Setup Authentication with gcloud
78+
uses: google-github-actions/setup-gcloud@master
79+
with:
80+
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
81+
export_default_credentials: true
82+
- name: Integration Tests
83+
run: npm run e2e-tests
84+
env:
85+
URL: ${{ steps.deploy.outputs.url }}
86+
87+
metadata:
88+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
89+
name: with full YAML metada
90+
runs-on: ubuntu-latest
91+
steps:
92+
- id: service
93+
run: echo ::set-output name=service::run-full-yaml-$GITHUB_SHA
94+
- uses: actions/checkout@v2
95+
- uses: actions/setup-node@master
96+
with:
97+
node-version: 12.x
98+
- name: Build Javascript
99+
run: |-
100+
npm install
101+
npm run build
102+
- name: Create service from metadata yaml
103+
id: deploy_1
104+
uses: ./
105+
with:
106+
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
107+
service: ${{ steps.service.outputs.service }}
108+
metadata: ./tests/unit/service.full.yaml
109+
- name: Setup Authentication with gcloud
110+
uses: google-github-actions/setup-gcloud@master
111+
with:
112+
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
113+
export_default_credentials: true
114+
- name: Integration Tests
115+
run: npm run e2e-tests
116+
env:
117+
URL: ${{ steps.deploy_1.outputs.url }}
118+
PARAMS: "{\"cpu\": 2,\"memory\": \"1Gi\", \"containerConcurrency\": 20}"
119+
ANNOTATIONS: "{\"run.googleapis.com/cloudsql-instances\": \"1:2:3\"}"
120+
LABELS: "{\"test_label\": \"test_value\"}"
121+
- name: Update service with new image
122+
id: deploy_2
123+
uses: ./
124+
with:
125+
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
126+
image: gcr.io/cloudrun/hello
127+
service: ${{ steps.service.outputs.service }}
128+
- name: Integration Tests # Check that config isn't overwritten
129+
run: npm run e2e-tests
130+
env:
131+
URL: ${{ steps.deploy_2.outputs.url }}
132+
SERVICE: ${{ steps.service.outputs.service }}
133+
PARAMS: "{\"cpu\": 2,\"memory\": \"1Gi\", \"containerConcurrency\": 20}"
134+
ANNOTATIONS: "{\"run.googleapis.com/cloudsql-instances\": \"1:2:3\"}"
135+
LABELS: "{\"test_label\": \"test_value\"}"
136+
137+
cleanup:
138+
name: Clean Up
139+
runs-on: ubuntu-latest
140+
needs: [envvars, metadata, yaml]
141+
steps:
142+
- uses: google-github-actions/setup-gcloud@master
143+
with:
144+
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
145+
project_id: ${{ secrets.DEPLOY_CLOUDRUN_PROJECT_ID }}
146+
- name: Delete services
147+
run: |-
148+
gcloud config set run/platform managed
149+
gcloud config set run/region us-central1
150+
gcloud run services delete run-full-yaml-$GITHUB_SHA --quiet
151+
gcloud run services delete run-yaml-$GITHUB_SHA --quiet
152+
gcloud run services delete run-envvars-$GITHUB_SHA --quiet

0 commit comments

Comments
 (0)