mirror of
https://github.com/pre-commit/action.git
synced 2025-11-09 03:26:56 +00:00
Fixed bug pushing to private repositories.
This commit is contained in:
parent
d0b0a000b5
commit
9df90cc07e
1 changed files with 4 additions and 3 deletions
7
index.js
7
index.js
|
|
@ -28,8 +28,8 @@ function hashFile(filePath) {
|
||||||
return hashString(fs.readFileSync(filePath).toString());
|
return hashString(fs.readFileSync(filePath).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToken(url, token) {
|
function addToken(token, repository) {
|
||||||
return url.replace(/^https:\/\//, `https://x-access-token:${token}@`);
|
return `https://${token}@github.com/${repository}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
@ -44,6 +44,7 @@ async function main() {
|
||||||
'--color=always',
|
'--color=always',
|
||||||
...tr.argStringToArray(core.getInput('extra_args')),
|
...tr.argStringToArray(core.getInput('extra_args')),
|
||||||
];
|
];
|
||||||
|
const repository = `${github.context.repo.owner}/${github.context.repo.repo}`;
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const pr = github.context.payload.pull_request;
|
const pr = github.context.payload.pull_request;
|
||||||
const push = !!token && !!pr;
|
const push = !!token && !!pr;
|
||||||
|
|
@ -77,7 +78,7 @@ async function main() {
|
||||||
await exec.exec('git', ['checkout', 'HEAD', '-b', branch]);
|
await exec.exec('git', ['checkout', 'HEAD', '-b', branch]);
|
||||||
|
|
||||||
await exec.exec('git', ['commit', '-am', 'pre-commit fixes']);
|
await exec.exec('git', ['commit', '-am', 'pre-commit fixes']);
|
||||||
const url = addToken(pr.head.repo.clone_url, token);
|
const url = addToken(repository, token);
|
||||||
await exec.exec('git', ['push', url, 'HEAD']);
|
await exec.exec('git', ['push', url, 'HEAD']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue