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