Added support for the CI_TOKEN
This commit is contained in:
35
app.ts
35
app.ts
@@ -8,6 +8,8 @@ const IGNORED_BRANCHES: string[] = core.getInput('branchesToIgnore', { required:
|
||||
|
||||
const mainBranch: string = `origin/${ core.getInput('mainBranch', { required: false }) }`;
|
||||
|
||||
const { CI_TOKEN, GITHUB_SERVER_URL } = process.env;
|
||||
|
||||
enum Action {
|
||||
Rebase = 0,
|
||||
Reset = 1
|
||||
@@ -206,7 +208,40 @@ const rebaseBranch = async ({
|
||||
]);
|
||||
}
|
||||
|
||||
const setupCIToken = async () => {
|
||||
writeConsole("Overriding git repository auth with CI_TOKEN")
|
||||
|
||||
const remoteUrl = await runGitCommand([
|
||||
"remote",
|
||||
"get-url",
|
||||
"origin"
|
||||
]);
|
||||
|
||||
const httpLessUrl = remoteUrl.replace(/https?:\/\//, "");
|
||||
const newUrl = `https://MilaBot:${ CI_TOKEN }@${ httpLessUrl }.git`;
|
||||
|
||||
await runGitCommand([
|
||||
"remote",
|
||||
"set-url",
|
||||
"origin",
|
||||
newUrl
|
||||
]);
|
||||
|
||||
await runGitCommand([
|
||||
"config",
|
||||
"--local",
|
||||
"--unset",
|
||||
`http.https://${ GITHUB_SERVER_URL }/.extraheader`
|
||||
]);
|
||||
}
|
||||
|
||||
const setupAutoRebaseGit = async () => {
|
||||
if (CI_TOKEN) {
|
||||
await setupCIToken();
|
||||
} else {
|
||||
writeConsole("Couldn't find a CI_TOKEN. Using the gitea ghost.", LogLevel.WARNING);
|
||||
}
|
||||
|
||||
await runGitCommand([
|
||||
"config",
|
||||
"user.email",
|
||||
|
||||
Reference in New Issue
Block a user