Skip to content

Commit 9997250

Browse files
authored
feat(action): use provided GH token (#514)
To process commits by this action it needs to re-trigger the CI. This is achieved by using personal access token (PAT) instead of the default GITHUB_TOKEN provided by the action. Also needs to set `persist-credentials: false` on checkout step.
1 parent 97c041e commit 9997250

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

action/src/platforms/github.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Octokit } from "octokit";
22
import { PlatformKit } from "./_base.js";
33
import Z from "zod";
4+
import { execSync } from "child_process";
45

56
export class GitHubPlatformKit extends PlatformKit {
67
private _octokit?: Octokit;
@@ -68,6 +69,19 @@ export class GitHubPlatformKit extends PlatformKit {
6869
});
6970
}
7071

72+
async gitConfig() {
73+
const { ghToken, repositoryOwner, repositoryName } = this.platformConfig;
74+
const { processOwnCommits } = this.config;
75+
76+
if (ghToken && processOwnCommits) {
77+
console.log("Using provided GH_TOKEN. This will trigger your CI/CD pipeline to run again.");
78+
79+
execSync(`git remote set-url origin https://${ghToken}@github.com/${repositoryOwner}/${repositoryName}.git`, {
80+
stdio: "inherit",
81+
});
82+
}
83+
}
84+
7185
get platformConfig() {
7286
const env = Z.object({
7387
GITHUB_REPOSITORY: Z.string(),

0 commit comments

Comments
 (0)