-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5af6c5c
commit 5be84ad
Showing
3 changed files
with
10 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,6 @@ import { | |
import { | ||
AuthClient, | ||
IAMCredentialsClient, | ||
ServiceAccountKeyClient, | ||
WorkloadIdentityFederationClient, | ||
} from './client/client'; | ||
import { Logger } from './logger'; | ||
|
@@ -48,8 +47,8 @@ import { | |
} from './utils'; | ||
import { appendFileSync } from 'fs'; | ||
import { relative } from 'path'; | ||
import * as core from '@actions/core' | ||
import axios, {isAxiosError} from 'axios' | ||
import * as core from '@actions/core'; | ||
import axios, { isAxiosError } from 'axios'; | ||
|
||
const secretsWarning = | ||
`If you are specifying input values via GitHub secrets, ensure the secret ` + | ||
|
@@ -62,27 +61,24 @@ const oidcWarning = | |
`GitHub Actions workflow permissions are incorrect, or this job is being ` + | ||
`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`; | ||
|
||
|
||
async function validateSubscription(): Promise<void> { | ||
const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription` | ||
const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`; | ||
|
||
try { | ||
await axios.get(API_URL, {timeout: 3000}) | ||
await axios.get(API_URL, { timeout: 3000 }); | ||
} catch (error) { | ||
if (isAxiosError(error) && error.response) { | ||
core.error( | ||
'Subscription is not valid. Reach out to [email protected]' | ||
) | ||
process.exit(1) | ||
core.error('Subscription is not valid. Reach out to [email protected]'); | ||
process.exit(1); | ||
} else { | ||
core.info('Timeout or API not reachable. Continuing to next step.') | ||
core.info('Timeout or API not reachable. Continuing to next step.'); | ||
} | ||
} | ||
} | ||
|
||
export async function run(logger: Logger) { | ||
// check subscription | ||
await validateSubscription() | ||
await validateSubscription(); | ||
|
||
// Warn if pinned to HEAD | ||
if (isPinnedToHead()) { | ||
|
@@ -149,7 +145,7 @@ export async function run(logger: Logger) { | |
serviceAccount: serviceAccount, | ||
}); | ||
} else { | ||
throw new Error('This action only supports workflow identity'); | ||
throw new Error('This action only supports workload identity'); | ||
} | ||
|
||
// Always write the credentials file first, before trying to generate | ||
|