Skip to content

Commit

Permalink
profile test code
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwoodworth committed Aug 29, 2023
1 parent 8800509 commit 055e764
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/handle-stale-discussions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: HandleStaleDiscussions
name: Handle Stale Discussions
on:
schedule:
- cron: '0 */4 * * *'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update dist files on main branch
name: Package dist files on main branch

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-integ.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run tests
name: Run integration tests

on:
workflow_dispatch:
Expand Down
18 changes: 11 additions & 7 deletions dist/cleanup/index.js

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

18 changes: 11 additions & 7 deletions dist/index.js

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

20 changes: 12 additions & 8 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ export function verifyKeys(creds: Partial<Credentials> | undefined) {
return true;
}

function determineProfilePath() {
function determineAwsPath() {
const os = platform();

switch (os) {
case 'darwin':
return `${process.env['HOME']}/.aws/credentials`;
return `${process.env['HOME']}/.aws`;
case 'linux':
return `${process.env['HOME']}/.aws/credentials`;
return `${process.env['HOME']}/.aws`;
case 'win32':
return `${process.env['USERPROFILE']}\\.aws\\credentials`;
return `${process.env['USERPROFILE']}\\.aws`;
default:
throw new Error(`Unexpected OS '${os}'`);
}
Expand All @@ -131,12 +131,12 @@ export function setProfile(profile: string, region: string, creds?: Partial<Cred
if (!profile) {
return;
}
const profilePath = determineProfilePath();
const profilePath = determineAwsPath();
const profileSection = `[${profile}]`;
const profileCreds = {
...creds,
AWS_REGION: region
}
AWS_REGION: region,
};
const profileCredsString = Object.keys(profileCreds)
.map((key) => `${key} = ${profileCreds[key as keyof Credentials]}`)
.join('\n');
Expand All @@ -146,7 +146,11 @@ export function setProfile(profile: string, region: string, creds?: Partial<Cred
core.debug(`Writing profile ${profile} to ${profilePath}`);
core.debug(`Profile string:\n${profileString}`);

fs.writeFileSync(profilePath, profileString);
fs.mkdirSync(profilePath, {
recursive: true,
});
const credentialsFilePath = platform() === 'win32' ? `${profilePath}\\credentials` : `${profilePath}/credentials`;
fs.writeFileSync(credentialsFilePath, profileString);
}

// Retries the promise with exponential backoff if the error isRetryable up to maxRetries time.
Expand Down

0 comments on commit 055e764

Please sign in to comment.