Skip to content

Commit

Permalink
bump up to v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Jan 12, 2024
1 parent 9a7a892 commit a9b5106
Show file tree
Hide file tree
Showing 184 changed files with 29,752 additions and 57 deletions.
2 changes: 0 additions & 2 deletions action/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/node_modules/
/lib/
/dummy.log
63 changes: 30 additions & 33 deletions action/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,32 @@ const core = __importStar(require("@actions/core"));
const http = __importStar(require("@actions/http-client"));
function validateGitHubToken(token) {
if (token.length < 4) {
throw new Error('GITHUB_TOKEN has invalid format');
throw new Error("GITHUB_TOKEN has invalid format");
}
switch (token.substring(0, 4)) {
case 'ghp_':
case "ghp_":
// Personal Access Tokens
throw new Error('GITHUB_TOKEN looks like Personal Access Token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.');
case 'gho_':
throw new Error("GITHUB_TOKEN looks like Personal Access Token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.");
case "gho_":
// OAuth Access tokens
throw new Error('GITHUB_TOKEN looks like OAuth Access token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.');
case 'ghu_':
throw new Error("GITHUB_TOKEN looks like OAuth Access token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.");
case "ghu_":
// GitHub App user-to-server tokens
throw new Error('GITHUB_TOKEN looks like GitHub App user-to-server token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.');
case 'ghs_':
throw new Error("GITHUB_TOKEN looks like GitHub App user-to-server token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.");
case "ghs_":
// GitHub App server-to-server tokens
return; // it's OK
case 'ghr_':
throw new Error('GITHUB_TOKEN looks like GitHub App refresh token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.');
case "ghr_":
throw new Error("GITHUB_TOKEN looks like GitHub App refresh token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.");
}
// maybe Old Format Personal Access Tokens
throw new Error('GITHUB_TOKEN looks like Personal Access Token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.');
throw new Error("GITHUB_TOKEN looks like Personal Access Token. `github-token` must be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`.");
}
// comes from the article "AWS federation comes to GitHub Actions"
// https://awsteele.com/blog/2021/09/15/aws-federation-comes-to-github-actions.html
function isIdTokenAvailable() {
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
const url = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
const token = process.env["ACTIONS_ID_TOKEN_REQUEST_TOKEN"];
const url = process.env["ACTIONS_ID_TOKEN_REQUEST_URL"];
return token && url ? true : false;
}
function assertIsDefined(val) {
Expand All @@ -69,7 +69,7 @@ async function assumeRole(params) {
assertIsDefined(GITHUB_ACTOR);
assertIsDefined(GITHUB_SHA);
validateGitHubToken(params.githubToken);
const GITHUB_API_URL = process.env['GITHUB_API_URL'] || 'https://api.github.com';
const GITHUB_API_URL = process.env["GITHUB_API_URL"] || "https://api.github.com";
let idToken;
if (isIdTokenAvailable()) {
idToken = await core.getIDToken();
Expand All @@ -83,15 +83,14 @@ async function assumeRole(params) {
api_url: GITHUB_API_URL,
repository: GITHUB_REPOSITORY,
use_node_id: params.useNodeId,
obfuscate_repository: params.obfuscateRepository,
sha: GITHUB_SHA,
role_session_tagging: params.roleSessionTagging,
run_id: GITHUB_RUN_ID,
workflow: GITHUB_WORKFLOW,
actor: GITHUB_ACTOR,
branch: GITHUB_REF || ''
branch: GITHUB_REF || "",
};
const client = new http.HttpClient('actions-aws-assume-role');
const client = new http.HttpClient("actions-aws-assume-role");
const result = await client.postJson(params.providerEndpoint, payload);
if (result.statusCode !== 200) {
const resp = result.result;
Expand All @@ -106,29 +105,28 @@ async function assumeRole(params) {
core.warning(resp.warning);
}
core.setSecret(resp.access_key_id);
core.exportVariable('AWS_ACCESS_KEY_ID', resp.access_key_id);
core.exportVariable("AWS_ACCESS_KEY_ID", resp.access_key_id);
core.setSecret(resp.secret_access_key);
core.exportVariable('AWS_SECRET_ACCESS_KEY', resp.secret_access_key);
core.exportVariable("AWS_SECRET_ACCESS_KEY", resp.secret_access_key);
core.setSecret(resp.session_token);
core.exportVariable('AWS_SESSION_TOKEN', resp.session_token);
core.exportVariable('AWS_DEFAULT_REGION', params.awsRegion);
core.exportVariable('AWS_REGION', params.awsRegion);
core.exportVariable("AWS_SESSION_TOKEN", resp.session_token);
core.exportVariable("AWS_DEFAULT_REGION", params.awsRegion);
core.exportVariable("AWS_REGION", params.awsRegion);
}
exports.assumeRole = assumeRole;
async function run() {
try {
const required = {
required: true
required: true,
};
const githubToken = core.getInput('github-token', required);
const awsRegion = core.getInput('aws-region', required);
const roleToAssume = core.getInput('role-to-assume', required);
const roleDurationSeconds = Number.parseInt(core.getInput('role-duration-seconds', required));
const roleSessionName = core.getInput('role-session-name', required);
const roleSessionTagging = core.getBooleanInput('role-session-tagging', required);
const providerEndpoint = core.getInput('provider-endpoint') || 'https://uw4qs7ndjj.execute-api.us-east-1.amazonaws.com/assume-role';
const useNodeId = core.getBooleanInput('use-node-id', required);
const obfuscateRepository = core.getInput('obfuscate-repository');
const githubToken = core.getInput("github-token", required);
const awsRegion = core.getInput("aws-region", required);
const roleToAssume = core.getInput("role-to-assume", required);
const roleDurationSeconds = Number.parseInt(core.getInput("role-duration-seconds", required));
const roleSessionName = core.getInput("role-session-name", required);
const roleSessionTagging = core.getBooleanInput("role-session-tagging", required);
const providerEndpoint = core.getInput("provider-endpoint") || "https://uw4qs7ndjj.execute-api.us-east-1.amazonaws.com/assume-role";
const useNodeId = core.getBooleanInput("use-node-id", required);
if (roleDurationSeconds <= 0 || roleDurationSeconds > 60 * 60) {
core.setFailed(`invalid role-duration-seconds ${roleDurationSeconds}, it should be from 1 to 3600`);
}
Expand All @@ -141,7 +139,6 @@ async function run() {
roleSessionTagging,
providerEndpoint,
useNodeId,
obfuscateRepository
});
}
catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions action/node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions action/node_modules/@actions/core/lib/core.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion action/node_modules/@actions/core/lib/oidc-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion action/node_modules/@actions/core/lib/oidc-utils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions action/node_modules/@actions/core/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions action/node_modules/@actions/http-client/lib/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 43 additions & 5 deletions action/node_modules/@actions/http-client/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion action/node_modules/@actions/http-client/lib/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions action/node_modules/@actions/http-client/lib/interfaces.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions action/node_modules/@actions/http-client/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a9b5106

Please sign in to comment.