Skip to content

Commit 5be84ad

Browse files
remove typo & update test workflow
1 parent 5af6c5c commit 5be84ad

File tree

3 files changed

+10
-138
lines changed

3 files changed

+10
-138
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,10 @@ jobs:
9090
project_id: '${{ vars.PROJECT_ID }}'
9191
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
9292

93-
- id: 'oauth-federated-token'
94-
name: 'oauth-federated-token'
95-
run: |-
96-
curl https://secretmanager.googleapis.com/v1/projects/${{ steps.auth-default.outputs.project_id }}/secrets/${{ vars.SECRET_NAME }}/versions/latest:access \
97-
--silent \
98-
--show-error \
99-
--fail \
100-
--header "Authorization: Bearer ${{ steps.auth-default.outputs.auth_token }}"
101-
10293
- uses: 'google-github-actions/setup-gcloud@v2'
10394
with:
10495
version: '>= 363.0.0'
10596

106-
- name: 'gcloud'
107-
run: |-
108-
gcloud secrets versions access "latest" --secret "${{ vars.SECRET_NAME }}"
109-
11097

11198
#
11299
# Workload Identity Federation through a Service Account
@@ -147,10 +134,6 @@ jobs:
147134
with:
148135
version: '>= 363.0.0'
149136

150-
- name: 'gcloud'
151-
run: |-
152-
gcloud secrets versions access "latest" --secret "${{ vars.SECRET_NAME }}"
153-
154137
- id: 'auth-access-token'
155138
name: 'auth-access-token'
156139
uses: './'
@@ -159,15 +142,6 @@ jobs:
159142
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
160143
token_format: 'access_token'
161144

162-
- id: 'oauth-token'
163-
name: 'oauth-token'
164-
run: |-
165-
curl https://secretmanager.googleapis.com/v1/projects/${{ steps.auth-access-token.outputs.project_id }}/secrets/${{ vars.SECRET_NAME }}/versions/latest:access \
166-
--silent \
167-
--show-error \
168-
--fail \
169-
--header "Authorization: Bearer ${{ steps.auth-access-token.outputs.access_token }}"
170-
171145
- id: 'id-token'
172146
name: 'id-token'
173147
uses: './'
@@ -177,101 +151,3 @@ jobs:
177151
token_format: 'id_token'
178152
id_token_audience: 'https://secretmanager.googleapis.com/'
179153
id_token_include_email: true
180-
181-
182-
#
183-
# Service Account Key JSON
184-
#
185-
credentials_json:
186-
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
187-
name: 'credentials_json'
188-
runs-on: '${{ matrix.os }}'
189-
strategy:
190-
fail-fast: false
191-
matrix:
192-
os:
193-
- 'ubuntu-latest'
194-
- 'windows-latest'
195-
- 'macos-latest'
196-
197-
steps:
198-
- uses: 'actions/checkout@v4'
199-
200-
- uses: 'actions/setup-node@v4'
201-
with:
202-
node-version: '20.x'
203-
204-
- name: 'npm build'
205-
run: 'npm ci && npm run build'
206-
207-
- id: 'auth-default'
208-
name: 'auth-default'
209-
uses: './'
210-
with:
211-
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
212-
213-
- uses: 'google-github-actions/setup-gcloud@v2'
214-
with:
215-
version: '>= 363.0.0'
216-
217-
- name: 'gcloud'
218-
run: |-
219-
gcloud secrets versions access "latest" --secret "${{ vars.SECRET_NAME }}"
220-
221-
- id: 'auth-access-token'
222-
name: 'auth-access-token'
223-
uses: './'
224-
with:
225-
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
226-
token_format: 'access_token'
227-
228-
- id: 'access-token'
229-
name: 'access-token'
230-
run: |-
231-
curl https://secretmanager.googleapis.com/v1/projects/${{ steps.auth-access-token.outputs.project_id }}/secrets/${{ vars.SECRET_NAME }}/versions/latest:access \
232-
--silent \
233-
--show-error \
234-
--fail \
235-
--header "Authorization: Bearer ${{ steps.auth-access-token.outputs.access_token }}"
236-
237-
- id: 'auth-id-token'
238-
name: 'auth-id-token'
239-
uses: './'
240-
with:
241-
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
242-
token_format: 'id_token'
243-
id_token_audience: 'https://secretmanager.googleapis.com/'
244-
id_token_include_email: true
245-
246-
#
247-
# This test ensures that the GOOGLE_APPLICATION_CREDENTIALS environment
248-
# variable is shared with the container and that the path of the file is on
249-
# the shared filesystem with the container and that the USER for the container
250-
# has permissions to read the file.
251-
#
252-
docker:
253-
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
254-
name: 'docker'
255-
runs-on: 'ubuntu-latest'
256-
strategy:
257-
fail-fast: false
258-
steps:
259-
- uses: 'actions/checkout@v4'
260-
261-
- uses: 'actions/setup-node@v4'
262-
with:
263-
node-version: '20.x'
264-
265-
- name: 'npm build'
266-
run: 'npm ci && npm run build'
267-
268-
- name: 'auth-default'
269-
uses: './'
270-
with:
271-
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
272-
273-
- name: 'docker'
274-
uses: 'docker://alpine:3'
275-
with:
276-
entrypoint: '/bin/sh'
277-
args: '-euc "test -n "${GOOGLE_APPLICATION_CREDENTIALS}" && test -r "${GOOGLE_APPLICATION_CREDENTIALS}"'

dist/main/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import {
3636
import {
3737
AuthClient,
3838
IAMCredentialsClient,
39-
ServiceAccountKeyClient,
4039
WorkloadIdentityFederationClient,
4140
} from './client/client';
4241
import { Logger } from './logger';
@@ -48,8 +47,8 @@ import {
4847
} from './utils';
4948
import { appendFileSync } from 'fs';
5049
import { relative } from 'path';
51-
import * as core from '@actions/core'
52-
import axios, {isAxiosError} from 'axios'
50+
import * as core from '@actions/core';
51+
import axios, { isAxiosError } from 'axios';
5352

5453
const secretsWarning =
5554
`If you are specifying input values via GitHub secrets, ensure the secret ` +
@@ -62,27 +61,24 @@ const oidcWarning =
6261
`GitHub Actions workflow permissions are incorrect, or this job is being ` +
6362
`run from a fork. For more information, please see https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token`;
6463

65-
6664
async function validateSubscription(): Promise<void> {
67-
const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`
65+
const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`;
6866

6967
try {
70-
await axios.get(API_URL, {timeout: 3000})
68+
await axios.get(API_URL, { timeout: 3000 });
7169
} catch (error) {
7270
if (isAxiosError(error) && error.response) {
73-
core.error(
74-
'Subscription is not valid. Reach out to [email protected]'
75-
)
76-
process.exit(1)
71+
core.error('Subscription is not valid. Reach out to [email protected]');
72+
process.exit(1);
7773
} else {
78-
core.info('Timeout or API not reachable. Continuing to next step.')
74+
core.info('Timeout or API not reachable. Continuing to next step.');
7975
}
8076
}
8177
}
8278

8379
export async function run(logger: Logger) {
8480
// check subscription
85-
await validateSubscription()
81+
await validateSubscription();
8682

8783
// Warn if pinned to HEAD
8884
if (isPinnedToHead()) {
@@ -149,7 +145,7 @@ export async function run(logger: Logger) {
149145
serviceAccount: serviceAccount,
150146
});
151147
} else {
152-
throw new Error('This action only supports workflow identity');
148+
throw new Error('This action only supports workload identity');
153149
}
154150

155151
// Always write the credentials file first, before trying to generate

0 commit comments

Comments
 (0)