Skip to content

Commit 53a3010

Browse files
committed
Add CI for release branches (#475)
1 parent 5081b8d commit 53a3010

File tree

4 files changed

+196
-3
lines changed

4 files changed

+196
-3
lines changed

.github/workflows/draft-release.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: 'Draft release'
216

317
on:
@@ -21,4 +35,4 @@ jobs:
2135
version_strategy: '${{ github.event.inputs.version_strategy }}'
2236
# secrets must be explicitly passed to reusable workflows https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow
2337
secrets:
24-
ACTIONS_BOT_TOKEN: '${{ secrets.ACTIONS_BOT_TOKEN }}'
38+
ACTIONS_BOT_TOKEN: '${{ secrets.ACTIONS_BOT_TOKEN }}'

.github/workflows/integration.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: 'Integration'
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'release/**/*'
8+
pull_request:
9+
branches:
10+
- 'main'
11+
- 'release/**/*'
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: 'read'
20+
id-token: 'write'
21+
22+
jobs:
23+
deploy:
24+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
25+
runs-on: 'ubuntu-latest'
26+
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- name: 'image'
32+
image: 'gcr.io/cloudrun/hello'
33+
- name: 'source'
34+
source: 'example-app'
35+
36+
name: 'from_${{ matrix.name }}'
37+
38+
steps:
39+
- uses: 'actions/checkout@v4'
40+
41+
- name: 'Compute service name'
42+
run: |-
43+
echo "SERVICE_NAME=${GITHUB_JOB}-${{ matrix.name }}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV}
44+
45+
- uses: 'actions/setup-node@v4'
46+
with:
47+
node-version: '20.x'
48+
49+
- run: 'npm ci && npm run build'
50+
51+
- uses: 'google-github-actions/auth@main'
52+
with:
53+
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
54+
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
55+
56+
- id: 'deploy-cloudrun'
57+
name: 'Deploy'
58+
uses: './'
59+
with:
60+
image: '${{ matrix.image }}'
61+
source: '${{ matrix.source }}'
62+
service: '${{ env.SERVICE_NAME }}'
63+
env_vars: |-
64+
FOO=bar
65+
ZIP=zap
66+
env_vars_file: './tests/fixtures/env_vars.txt'
67+
secrets: |-
68+
MY_SECRET=${{ vars.SECRET_NAME }}:latest
69+
MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
70+
labels: |-
71+
label1=value1
72+
label2=value2
73+
skip_default_labels: true
74+
flags: '--cpu=2 --concurrency=20'
75+
76+
- run: 'npm run e2e-tests'
77+
env:
78+
PROJECT_ID: ${{ vars.PROJECT_ID }}
79+
SERVICE: '${{ env.SERVICE_NAME }}'
80+
ENV: 'FOO=bar,ZIP=zap,TEXT_FOO=bar,TEXT_ZIP=zap'
81+
SECRET_ENV: MY_SECRET=${{ vars.SECRET_NAME }}:latest,MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
82+
PARAMS: '{"cpu":2, "containerConcurrency":20}'
83+
LABELS: '{"label1":"value1", "label2":"value2"}'
84+
85+
- id: 'deploy-cloudrun-again'
86+
name: 'Deploy again'
87+
uses: './'
88+
with:
89+
image: '${{ matrix.image }}'
90+
source: '${{ matrix.source }}'
91+
service: '${{ env.SERVICE_NAME }}'
92+
env_vars: |-
93+
ABC=123
94+
DEF=456
95+
secrets: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest
96+
97+
- run: 'npm run e2e-tests'
98+
env:
99+
PROJECT_ID: ${{ vars.PROJECT_ID }}
100+
SERVICE: '${{ env.SERVICE_NAME }}'
101+
ENV: 'FOO=bar,ZIP=zap,TEXT_FOO=bar,TEXT_ZIP=zap,ABC=123,DEF=456'
102+
SECRET_ENV: MY_SECRET=${{ vars.SECRET_NAME }}:latest,MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
103+
SECRET_VOLUMES: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest
104+
PARAMS: '{"cpu":2, "containerConcurrency":20}'
105+
LABELS: '{"label1":"value1", "label2":"value2", "commit-sha":"${{ github.sha }}", "managed-by":"github-actions"}'
106+
REVISION_COUNT: 2
107+
108+
metadata:
109+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
110+
runs-on: 'ubuntu-latest'
111+
112+
steps:
113+
- uses: 'actions/checkout@v4'
114+
115+
- name: 'Compute service name'
116+
run: |-
117+
echo "SERVICE_NAME=${GITHUB_JOB}-metadata-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV}
118+
119+
- name: 'Set service name in metadata YAML'
120+
run: |-
121+
sed -i "s/run-full-yaml/${{ env.SERVICE_NAME }}/" ./tests/unit/service.yaml
122+
123+
- uses: 'actions/setup-node@v4'
124+
with:
125+
node-version: '20.x'
126+
127+
- run: 'npm ci && npm run build'
128+
129+
- uses: 'google-github-actions/auth@main'
130+
with:
131+
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
132+
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
133+
134+
- id: 'deploy-cloudrun'
135+
name: 'Deploy'
136+
uses: './'
137+
with:
138+
metadata: './tests/unit/service.yaml'
139+
140+
- run: 'npm run e2e-tests'
141+
env:
142+
PROJECT_ID: '${{ vars.PROJECT_ID }}'
143+
SERVICE: '${{ env.SERVICE_NAME }}'
144+
PARAMS: '{"cpu":2, "memory":"1Gi", "containerConcurrency":20}'
145+
ANNOTATIONS: '{"run.googleapis.com/cloudsql-instances":"test-project:us-central1:my-test-instance"}'
146+
LABELS: '{"test_label":"test_value"}'
147+
148+
- id: 'deploy-cloudrun-again'
149+
name: 'Deploy again'
150+
uses: './'
151+
with:
152+
image: 'gcr.io/cloudrun/hello'
153+
service: '${{ env.SERVICE_NAME }}'
154+
155+
- run: 'npm run e2e-tests' # Check that config isn't overwritten
156+
env:
157+
PROJECT_ID: '${{ vars.PROJECT_ID }}'
158+
SERVICE: '${{ env.SERVICE_NAME }}'
159+
PARAMS: '{"cpu":2, "memory":"1Gi", "containerConcurrency":20}'
160+
ANNOTATIONS: '{"run.googleapis.com/cloudsql-instances":"test-project:us-central1:my-test-instance"}'
161+
REVISION_COUNT: 2

.github/workflows/release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: 'Release'
216

317
on:
418
push:
519
branches:
620
- 'main'
21+
- 'release/**/*'
722

823
jobs:
924
release:

.github/workflows/unit.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ name: 'unit'
33
on:
44
push:
55
branches:
6-
- 'main'
6+
- 'main'
7+
- 'release/**/*'
78
pull_request:
89
branches:
9-
- 'main'
10+
- 'main'
11+
- 'release/**/*'
12+
workflow_dispatch:
1013

1114
concurrency:
1215
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'

0 commit comments

Comments
 (0)