Skip to content

Commit

Permalink
fix: Fail fast if githubToken not supplied
Browse files Browse the repository at this point in the history
Previously if `githubToken` was not supplied we'd fail at the point of commenting.

This change fails at the start.
  • Loading branch information
akash1810 committed Nov 20, 2023
1 parent 34464fc commit adbca41
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63703,7 +63703,7 @@ function getConfiguration() {
projectName,
buildNumber,
commentingStage,
githubToken
githubToken: githubToken()
}
};
}
Expand Down Expand Up @@ -63749,7 +63749,7 @@ function getCommentMessage(config) {
}
async function commentOnPullRequest(pullRequestNumber, config) {
const comment = getCommentMessage(config);
const octokit = (0, import_github.getOctokit)(config.githubToken());
const octokit = (0, import_github.getOctokit)(config.githubToken);
const comments = await octokit.rest.issues.listComments({
...import_github.context.repo,
issue_number: pullRequestNumber
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export interface PullRequestCommentConfig {
projectName: string;
buildNumber: string;
commentingStage: string;
githubToken: () => string;
githubToken: string;
}

export interface Configuration {
Expand Down Expand Up @@ -208,7 +208,7 @@ export function getConfiguration(): Configuration {
projectName,
buildNumber,
commentingStage,
githubToken,
githubToken: githubToken(),
},
};
}
1 change: 1 addition & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('action', () => {

const input = `dryRun: true
app: foo
githubToken: ${process.env['GITHUB_SECRET'] ?? 'dev'}
stagingDir: staging
contentDirectories: |
upload:
Expand Down
2 changes: 1 addition & 1 deletion src/pr-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function commentOnPullRequest(
config: PullRequestCommentConfig,
) {
const comment = getCommentMessage(config);
const octokit = getOctokit(config.githubToken());
const octokit = getOctokit(config.githubToken);

const comments = await octokit.rest.issues.listComments({
...context.repo,
Expand Down

0 comments on commit adbca41

Please sign in to comment.