48
48
- name : ' npm test'
49
49
run : ' npm run test'
50
50
51
- credentials_json :
51
+
52
+ #
53
+ # Direct Workload Identity Federation
54
+ #
55
+ direct_workload_identity_federation :
52
56
if : ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
53
- name : ' credentials_json '
57
+ name : ' direct_workload_identity_federation '
54
58
runs-on : ' ${{ matrix.os }}'
55
59
strategy :
56
60
fail-fast : false
60
64
- ' windows-latest'
61
65
- ' macos-latest'
62
66
67
+ permissions :
68
+ id-token : ' write'
69
+
63
70
steps :
64
71
- uses : ' actions/checkout@v4'
65
72
@@ -74,11 +81,60 @@ jobs:
74
81
name : ' auth-default'
75
82
uses : ' ./'
76
83
with :
77
- credentials_json : ' ${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
84
+ project_id : ' ${{ vars.PROJECT_ID }}'
85
+ workload_identity_provider : ' ${{ vars.WIF_PROVIDER_NAME }}'
86
+
87
+ - id : ' gcloud'
88
+ name : ' gcloud'
89
+ shell : ' bash'
90
+ run : |-
91
+ gcloud secrets versions access "latest" --secret "${{ vars.SECRET_NAME }}"
92
+
93
+ - id : ' oauth-federated-token'
94
+ name : ' oauth-federated-token'
95
+ shell : ' bash'
96
+ run : |-
97
+ curl https://secretmanager.googleapis.com/v1/projects/${{ steps.auth-default.outputs.project_id }}/secrets/${{ vars.SECRET_NAME }}/versions/latest:access \
98
+ --silent \
99
+ --show-error \
100
+ --fail \
101
+ --header "Authorization: Bearer ${{ steps.auth-default.outputs.auth_token }}"
102
+
103
+
104
+ #
105
+ # Workload Identity Federation through a Service Account
106
+ #
107
+ workload_identity_federation_through_service_account :
108
+ if : ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
109
+ name : ' workload_identity_federation_through_service_account'
110
+ runs-on : ' ${{ matrix.os }}'
111
+ strategy :
112
+ fail-fast : false
113
+ matrix :
114
+ os :
115
+ - ' ubuntu-latest'
116
+ - ' windows-latest'
117
+ - ' macos-latest'
118
+
119
+ permissions :
120
+ id-token : ' write'
121
+
122
+ steps :
123
+ - uses : ' actions/checkout@v4'
124
+
125
+ - uses : ' actions/setup-node@v4'
126
+ with :
127
+ node-version : ' 20.x'
128
+
129
+ - name : ' npm build'
130
+ run : ' npm ci && npm run build'
78
131
79
- - id : ' setup-gcloud'
80
- name : ' setup-gcloud'
81
- uses : ' google-github-actions/setup-gcloud@main'
132
+ - id : ' auth-default'
133
+ name : ' auth-default'
134
+ uses : ' ./'
135
+ with :
136
+ workload_identity_provider : ' ${{ vars.WIF_PROVIDER_NAME }}'
137
+ service_account : ' ${{ vars.SERVICE_ACCOUNT_EMAIL }}'
82
138
83
139
- id : ' gcloud'
84
140
name : ' gcloud'
@@ -90,11 +146,12 @@ jobs:
90
146
name : ' auth-access-token'
91
147
uses : ' ./'
92
148
with :
93
- credentials_json : ' ${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
149
+ workload_identity_provider : ' ${{ vars.WIF_PROVIDER_NAME }}'
150
+ service_account : ' ${{ vars.SERVICE_ACCOUNT_EMAIL }}'
94
151
token_format : ' access_token'
95
152
96
- - id : ' access -token'
97
- name : ' access -token'
153
+ - id : ' oauth -token'
154
+ name : ' oauth -token'
98
155
shell : ' bash'
99
156
run : |-
100
157
curl https://secretmanager.googleapis.com/v1/projects/${{ steps.auth-access-token.outputs.project_id }}/secrets/${{ vars.SECRET_NAME }}/versions/latest:access \
@@ -103,27 +160,23 @@ jobs:
103
160
--fail \
104
161
--header "Authorization: Bearer ${{ steps.auth-access-token.outputs.access_token }}"
105
162
106
- - id : ' auth- id-token'
107
- name : ' auth- id-token'
163
+ - id : ' id-token'
164
+ name : ' id-token'
108
165
uses : ' ./'
109
166
with :
110
- credentials_json : ' ${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
167
+ workload_identity_provider : ' ${{ vars.WIF_PROVIDER_NAME }}'
168
+ service_account : ' ${{ vars.SERVICE_ACCOUNT_EMAIL }}'
111
169
token_format : ' id_token'
112
170
id_token_audience : ' https://secretmanager.googleapis.com/'
113
171
id_token_include_email : true
114
172
115
- - id : ' auth-sa-retries'
116
- name : ' auth-sa-retries'
117
- uses : ' ./'
118
- with :
119
- retries : ' 2'
120
- backoff : ' 200'
121
- backoff_limit : ' 1000'
122
- credentials_json : ' ${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
123
173
124
- workload_identity_federation :
174
+ #
175
+ # Service Account Key JSON
176
+ #
177
+ credentials_json :
125
178
if : ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
126
- name : ' workload_identity_federation '
179
+ name : ' credentials_json '
127
180
runs-on : ' ${{ matrix.os }}'
128
181
strategy :
129
182
fail-fast : false
@@ -133,9 +186,6 @@ jobs:
133
186
- ' windows-latest'
134
187
- ' macos-latest'
135
188
136
- permissions :
137
- id-token : ' write'
138
-
139
189
steps :
140
190
- uses : ' actions/checkout@v4'
141
191
@@ -150,12 +200,7 @@ jobs:
150
200
name : ' auth-default'
151
201
uses : ' ./'
152
202
with :
153
- workload_identity_provider : ' ${{ vars.WIF_PROVIDER_NAME }}'
154
- service_account : ' ${{ vars.SERVICE_ACCOUNT_EMAIL }}'
155
-
156
- - id : ' setup-gcloud'
157
- name : ' setup-gcloud'
158
- uses : ' google-github-actions/setup-gcloud@main'
203
+ credentials_json : ' ${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
159
204
160
205
- id : ' gcloud'
161
206
name : ' gcloud'
@@ -167,8 +212,7 @@ jobs:
167
212
name : ' auth-access-token'
168
213
uses : ' ./'
169
214
with :
170
- workload_identity_provider : ' ${{ vars.WIF_PROVIDER_NAME }}'
171
- service_account : ' ${{ vars.SERVICE_ACCOUNT_EMAIL }}'
215
+ credentials_json : ' ${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
172
216
token_format : ' access_token'
173
217
174
218
- id : ' access-token'
@@ -185,26 +229,26 @@ jobs:
185
229
name : ' auth-id-token'
186
230
uses : ' ./'
187
231
with :
188
- workload_identity_provider : ' ${{ vars.WIF_PROVIDER_NAME }}'
189
- service_account : ' ${{ vars.SERVICE_ACCOUNT_EMAIL }}'
232
+ credentials_json : ' ${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
190
233
token_format : ' id_token'
191
234
id_token_audience : ' https://secretmanager.googleapis.com/'
192
235
id_token_include_email : true
193
236
194
- - id : ' auth-wif -retries'
195
- name : ' auth-wif -retries'
237
+ - id : ' auth-sa -retries'
238
+ name : ' auth-sa -retries'
196
239
uses : ' ./'
197
240
with :
198
241
retries : ' 2'
199
242
backoff : ' 200'
200
243
backoff_limit : ' 1000'
201
- workload_identity_provider : ' ${{ vars.WIF_PROVIDER_NAME }}'
202
- service_account : ' ${{ vars.SERVICE_ACCOUNT_EMAIL }}'
244
+ credentials_json : ' ${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
203
245
246
+ #
204
247
# This test ensures that the GOOGLE_APPLICATION_CREDENTIALS environment
205
248
# variable is shared with the container and that the path of the file is on
206
249
# the shared filesystem with the container and that the USER for the container
207
250
# has permissions to read the file.
251
+ #
208
252
docker :
209
253
if : ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
210
254
name : ' docker'
0 commit comments