Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Only run push for pull requests
  • Loading branch information
asottile committed Jan 9, 2020
1 parent 14f0840 commit b25e7c29f3ab5d643ab171551faebb9525feec7b
Showing 1 changed file with 3 additions and 3 deletions.
@@ -17,7 +17,8 @@ async function main() {
});

const token = core.getInput('token');
const push = !!token;
const pr = github.context.payload.pull_request;
const push = !!token && !!pr;
const ret = await exec.exec('pre-commit', ARGS, {ignoreReturnCode: push});
if (ret && push) {
// actions do not run on pushes made by actions.
@@ -35,11 +36,10 @@ async function main() {
'git', ['config', 'user.email', 'pre-commit@example.com']
);

const branch = github.context.payload.pull_request.head.ref;
const branch = pr.head.ref;
await exec.exec('git', ['checkout', 'HEAD', '-b', branch]);

await exec.exec('git', ['commit', '-am', 'pre-commit fixes']);
const pr = github.context.payload.pull_request;
const url = addToken(pr.head.repo.clone_url, token);
await exec.exec('git', ['remote', 'set-url', 'origin', url]);
await exec.exec('git', ['push', 'origin', 'HEAD']);

0 comments on commit b25e7c2

Please sign in to comment.