Skip to content

Commit 96dfc9f

Browse files
authored
Update docs to list full job and pin auth to @v0 (#259)
1 parent 92e1db9 commit 96dfc9f

File tree

4 files changed

+106
-81
lines changed

4 files changed

+106
-81
lines changed

.github/workflows/deploy-cloudrun-credentials-it.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
npm run build
2424
2525
- name: Set up authentication
26-
uses: google-github-actions/setup-gcloud@master
26+
uses: google-github-actions/setup-gcloud@v0
2727
with:
2828
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
2929
export_default_credentials: true
@@ -61,7 +61,7 @@ jobs:
6161
image: gcr.io/cloudrun/hello
6262
service: ${{ steps.service.outputs.service }}
6363

64-
- uses: google-github-actions/setup-gcloud@master # Set up ADC to make authenticated request to service
64+
- uses: google-github-actions/setup-gcloud@v0 # Set up ADC to make authenticated request to service
6565
with:
6666
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
6767
export_default_credentials: true
@@ -93,7 +93,7 @@ jobs:
9393
image: gcr.io/cloudrun/hello
9494
service: ${{ steps.service.outputs.service }}
9595

96-
- uses: google-github-actions/setup-gcloud@master # Set up ADC to make authenticated request to service
96+
- uses: google-github-actions/setup-gcloud@v0 # Set up ADC to make authenticated request to service
9797
with:
9898
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
9999
export_default_credentials: true
@@ -137,7 +137,7 @@ jobs:
137137
image: gcr.io/cloudrun/hello
138138
service: ${{ steps.service.outputs.service }}
139139

140-
- uses: google-github-actions/setup-gcloud@master # Set up ADC to make authenticated request to service
140+
- uses: google-github-actions/setup-gcloud@v0 # Set up ADC to make authenticated request to service
141141
with:
142142
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
143143
export_default_credentials: true
@@ -153,7 +153,7 @@ jobs:
153153
runs-on: ubuntu-latest
154154
needs: [json, gcloud, b64_json, wif]
155155
steps:
156-
- uses: google-github-actions/setup-gcloud@master
156+
- uses: google-github-actions/setup-gcloud@v0
157157
with:
158158
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
159159
project_id: ${{ secrets.DEPLOY_CLOUDRUN_PROJECT_ID }}

.github/workflows/deploy-cloudrun-traffic-it.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: deploy-cloudrun Traffic Integration
22

33
on:
44
push:
5-
branches:
5+
branches:
66
- 'main'
77
pull_request:
88

@@ -32,7 +32,7 @@ jobs:
3232
source: example-app
3333

3434
- name: Setup Authentication with gcloud
35-
uses: google-github-actions/setup-gcloud@master
35+
uses: google-github-actions/setup-gcloud@v0
3636
with:
3737
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
3838
export_default_credentials: true
@@ -87,7 +87,7 @@ jobs:
8787
suffix: "002"
8888

8989
- name: Setup Authentication with gcloud
90-
uses: google-github-actions/setup-gcloud@master
90+
uses: google-github-actions/setup-gcloud@v0
9191
with:
9292
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
9393
export_default_credentials: true
@@ -98,7 +98,7 @@ jobs:
9898
URL: ${{ steps.deploy_1.outputs.url }}
9999
SERVICE: ${{ steps.service.outputs.service }}
100100
REVISION: ${{ steps.service.outputs.service }}-002
101-
101+
102102
tag:
103103
name: with Tag
104104
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
@@ -126,7 +126,7 @@ jobs:
126126
tag: test-tag
127127

128128
- name: Setup Authentication with gcloud
129-
uses: google-github-actions/setup-gcloud@master
129+
uses: google-github-actions/setup-gcloud@v0
130130
with:
131131
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
132132
export_default_credentials: true
@@ -154,7 +154,7 @@ jobs:
154154
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
155155
service: ${{ steps.service.outputs.service }}
156156
tag_traffic: "test-tag=100"
157-
157+
158158
- name: Integration Tests
159159
run: npm run e2e-tests
160160
env:
@@ -170,7 +170,7 @@ jobs:
170170
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
171171
service: ${{ steps.service.outputs.service }}
172172
revision_traffic: "${{ steps.service.outputs.service }}-v2=20"
173-
173+
174174
- name: Integration Tests
175175
run: npm run e2e-tests
176176
env:
@@ -203,7 +203,7 @@ jobs:
203203
runs-on: ubuntu-latest
204204
needs: [source, suffix, tag]
205205
steps:
206-
- uses: google-github-actions/setup-gcloud@master
206+
- uses: google-github-actions/setup-gcloud@v0
207207
with:
208208
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
209209
project_id: ${{ secrets.DEPLOY_CLOUDRUN_PROJECT_ID }}

.github/workflows/example-workflow.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions/checkout@v2
3232

3333
- name: Setup Cloud SDK
34-
uses: google-github-actions/setup-gcloud@v0.2.0
34+
uses: google-github-actions/setup-gcloud@v0
3535
with:
3636
project_id: ${{ env.PROJECT_ID }}
3737
service_account_key: ${{ secrets.GCP_SA_KEY }}
@@ -44,7 +44,7 @@ jobs:
4444
run: |-
4545
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} example-app/
4646
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}
47-
47+
4848
- name: Deploy to Cloud Run
4949
id: deploy
5050
uses: google-github-actions/[email protected]

README.md

Lines changed: 91 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,27 @@ Cloud Run service. See the [Credentials](#credentials) below for more informatio
4646
## Usage
4747

4848
```yaml
49-
- id: auth
50-
uses: google-github-actions/[email protected]
51-
with:
52-
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
53-
service_account: '[email protected]'
54-
55-
- name: Deploy to Cloud Run
56-
id: deploy
57-
uses: google-github-actions/[email protected]
58-
with:
59-
service: hello-cloud-run 
60-
image: gcr.io/cloudrun/hello
61-
62-
- name: Use Output
63-
run: curl "${{ steps.deploy.outputs.url }}"
49+
jobs:
50+
job_id:
51+
permissions:
52+
contents: 'read'
53+
id-token: 'write'
54+
55+
steps:
56+
- id: 'auth'
57+
uses: 'google-github-actions/auth@v0'
58+
with:
59+
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
60+
service_account: '[email protected]'
61+
62+
- id: 'deploy'
63+
uses: 'google-github-actions/[email protected]'
64+
with:
65+
service: 'hello-cloud-run'
66+
image: 'gcr.io/cloudrun/hello'
67+
68+
- name: 'Use output'
69+
run: 'curl "${{ steps.deploy.outputs.url }}"'
6470
```
6571
6672
## Inputs
@@ -149,32 +155,42 @@ one of the methods found in [Configuring Ownership and access to a service accou
149155
#### Authenticating via Workload Identity Federation
150156

151157
```yaml
152-
- id: 'auth'
153-
uses: 'google-github-actions/[email protected]'
154-
with:
155-
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
156-
service_account: '[email protected]'
157-
158-
- name: Deploy to Cloud Run
159-
uses: google-github-actions/[email protected]
160-
with:
161-
image: gcr.io/cloudrun/hello
162-
service: hello-cloud-run
158+
jobs:
159+
job_id:
160+
permissions:
161+
contents: 'read'
162+
id-token: 'write'
163+
164+
steps:
165+
- id: 'auth'
166+
uses: 'google-github-actions/auth@v0'
167+
with:
168+
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
169+
service_account: '[email protected]'
170+
171+
- name: 'Deploy to Cloud Run'
172+
uses: 'google-github-actions/[email protected]'
173+
with:
174+
image: 'gcr.io/cloudrun/hello'
175+
service: 'hello-cloud-run'
163176
```
164177

165178
#### Authenticating via Service Account Key JSON
166179

167180
```yaml
168-
- id: 'auth'
169-
uses: 'google-github-actions/[email protected]'
170-
with:
171-
credentials_json: '${{ secrets.GCP_SA_KEY }}'
172-
173-
- name: Deploy to Cloud Run
174-
uses: google-github-actions/[email protected]
175-
with:
176-
image: gcr.io/cloudrun/hello
177-
service: hello-cloud-run
181+
jobs:
182+
job_id:
183+
steps:
184+
- id: 'auth'
185+
uses: 'google-github-actions/auth@v0'
186+
with:
187+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
188+
189+
- name: 'Deploy to Cloud Run'
190+
uses: 'google-github-actions/[email protected]'
191+
with:
192+
image: 'gcr.io/cloudrun/hello'
193+
service: 'hello-cloud-run'
178194
```
179195

180196
### Via Application Default Credentials
@@ -185,11 +201,14 @@ authenticate requests as the service account attached to the instance. **This
185201
only works using a custom runner hosted on GCP.**
186202

187203
```yaml
188-
- name: Deploy to Cloud Run
189-
uses: google-github-actions/[email protected]
190-
with:
191-
image: gcr.io/cloudrun/hello
192-
service: hello-cloud-run
204+
jobs:
205+
job_id:
206+
steps:
207+
- name: 'Deploy to Cloud Run'
208+
uses: 'google-github-actions/[email protected]'
209+
with:
210+
image: 'gcr.io/cloudrun/hello'
211+
service: 'hello-cloud-run'
193212
```
194213

195214
## Example Workflows
@@ -245,36 +264,42 @@ git push YOUR-FORK main:example-build-deploy
245264
Example using `setup-gcloud`:
246265

247266
```YAML
248-
- name: Setup Cloud SDK
249-
uses: google-github-actions/[email protected]
250-
with:
251-
project_id: ${{ env.PROJECT_ID }}
252-
service_account_key: ${{ secrets.GCP_SA_KEY }}
253-
254-
- name: Deploy to Cloud Run
255-
run: |-
256-
gcloud run deploy $SERVICE \
257-
--region $REGION \
258-
--image gcr.io/$PROJECT_ID/$SERVICE \
259-
--platform managed \
260-
--set-env-vars NAME="Hello World"
267+
jobs:
268+
job_id:
269+
steps:
270+
- name: 'Setup Cloud SDK'
271+
uses: 'google-github-actions/setup-gcloud@v0'
272+
with:
273+
project_id: '${{ env.PROJECT_ID }}'
274+
service_account_key: '${{ secrets.GCP_SA_KEY }}'
275+
276+
- name: 'Deploy to Cloud Run'
277+
run: |-
278+
gcloud run deploy $SERVICE \
279+
--region $REGION \
280+
--image gcr.io/$PROJECT_ID/$SERVICE \
281+
--platform managed \
282+
--set-env-vars NAME="Hello World"
261283
```
262284

263285
Migrated to `deploy-cloudrun`:
264286

265287
```YAML
266-
- id: 'auth'
267-
uses: 'google-github-actions/[email protected]'
268-
with:
269-
credentials_json: '${{ secrets.GCP_SA_KEY }}'
270-
271-
- name: Deploy to Cloud Run
272-
uses: google-github-actions/[email protected]
273-
with:
274-
service: ${{ env.SERVICE }}
275-
image: gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}
276-
region: ${{ env.REGION }}
277-
env_vars: NAME="Hello World"
288+
jobs:
289+
job_id:
290+
steps:
291+
- id: 'auth'
292+
uses: 'google-github-actions/auth@v0'
293+
with:
294+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
295+
296+
- name: 'Deploy to Cloud Run'
297+
uses: 'google-github-actions/[email protected]'
298+
with:
299+
service: '${{ env.SERVICE }}'
300+
image: 'gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}'
301+
region: '${{ env.REGION }}'
302+
env_vars: 'NAME="Hello World"'
278303
```
279304
Note: The action is for the "managed" platform and will not set access privileges such as [allowing unauthenticated requests](#Allow-unauthenticated-requests).
280305

0 commit comments

Comments
 (0)