Added support for the CI_TOKEN
This commit is contained in:
@@ -14,5 +14,7 @@ inputs:
|
||||
required: false
|
||||
|
||||
runs:
|
||||
env:
|
||||
CI_TOKEN: "${{ secrets.CI_TOKEN }}"
|
||||
using: 'node20'
|
||||
main: 'dist/app.js'
|
||||
|
||||
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",
|
||||
|
||||
80
dist/app.js
vendored
80
dist/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/package.json
vendored
2
dist/package.json
vendored
@@ -5,7 +5,7 @@
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"prepare": "husky",
|
||||
"build": "cp package.json dist/ && sed -i '' -E 's/\"type\": \".*$//' dist/package.json && esbuild --outdir=dist --bundle --platform=node --minify --format=cjs --allow-overwrite ./app.ts",
|
||||
"build": "cp package.json dist/ && sed -i -E 's/\"type\": \".*$//' dist/package.json && esbuild --outdir=dist --bundle --platform=node --minify --format=cjs --allow-overwrite ./app.ts",
|
||||
"dev": "tsx app.ts"
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user