Skip to content

Commit

Permalink
fix: ensure token is masked (#4)
Browse files Browse the repository at this point in the history
* fix: ensure token is masked

* chore: use github action token for dry run release.
  • Loading branch information
npalm authored Mar 14, 2021
1 parent e4ccc0a commit c598664
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Dry run release
env:
GITHUB_TOKEN: ${{ steps.app.outputs.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn && yarn run release -d -b ${{ steps.branch.outputs.short_ref }}

- name: Release
Expand Down
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15302,7 +15302,7 @@ const getAppInstallationToken = (privateKey, appId, org) => __awaiter(void 0, vo
});
exports.getAppInstallationToken = getAppInstallationToken;
const getToken = (parameters) => __awaiter(void 0, void 0, void 0, function* () {
let token = undefined;
let token;
const privateKey = Buffer.from(parameters.base64PrivateKey, 'base64').toString();
switch (parameters.type) {
case 'installation': {
Expand Down Expand Up @@ -15374,6 +15374,8 @@ function run() {
type: authType,
org,
});
// some github magic seems masking the token by default, but just to ensure it is registered as secret.
core.setSecret(token);
core.setOutput('token', token);
}
catch (error) {
Expand Down
5 changes: 3 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const getAppInstallationToken = async (privateKey: string, appId: number,
}
};

export const getToken = async (parameters: Parameters): Promise<string | undefined> => {
let token = undefined;
export const getToken = async (parameters: Parameters): Promise<string> => {
let token: string;

const privateKey = Buffer.from(parameters.base64PrivateKey, 'base64').toString();
switch (parameters.type) {
Expand All @@ -58,5 +58,6 @@ export const getToken = async (parameters: Parameters): Promise<string | undefin
break;
}
}

return token;
};
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ async function run(): Promise<void> {
org,
});

// some github magic seems masking the token by default, but just to ensure it is registered as secret.
core.setSecret(token);
core.setOutput('token', token);
} catch (error) {
core.debug(error);
Expand Down

0 comments on commit c598664

Please sign in to comment.