feat: Have an ability to configure session name (#29)

* 1. Add 'role-session-name' variable to action.yml
2. Configure roleSessionName with role-session-name from action or default value (GitHubActions)

* Add description on README.md

* update README.md

* update dist/index.js

* add test code

* update context based on comments
This commit is contained in:
Chuan-Yen Chiang
2020-03-01 20:47:10 +01:00
committed by GitHub
parent 058322d68a
commit 4d0082acf8
5 changed files with 42 additions and 11 deletions

View File

@@ -238,6 +238,28 @@ describe('Configure AWS Credentials', () => {
})
});
test('role assumption session name provided', async () => {
core.getInput = jest
.fn()
.mockImplementation(mockGetInput({...ASSUME_ROLE_INPUTS, 'role-session-name': 'MySessionName'}));
await run();
expect(mockStsAssumeRole).toHaveBeenCalledWith({
RoleArn: ROLE_NAME,
RoleSessionName: 'MySessionName',
DurationSeconds: 6 * 3600,
Tags: [
{Key: 'GitHub', Value: 'Actions'},
{Key: 'Repository', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REPOSITORY},
{Key: 'Workflow', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_WORKFLOW},
{Key: 'Action', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_ACTION},
{Key: 'Actor', Value: GITHUB_ACTOR_SANITIZED},
{Key: 'Branch', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REF},
{Key: 'Commit', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_SHA},
]
})
});
test('workflow name sanitized in role assumption tags', async () => {
core.getInput = jest
.fn()