5
0
Fork 0
mirror of https://github.com/pre-commit/action.git synced 2025-11-09 11:36:55 +00:00

Allow action user to use custom commit message

This commit is contained in:
Aaron Mak 2020-07-01 12:00:10 +08:00
parent 56c4e645ab
commit 7e5ba9a98c
No known key found for this signature in database
GPG key ID: C34A558918371145
3 changed files with 18 additions and 1 deletions

View file

@ -69,3 +69,15 @@ while you could _technically_ configure this for a public repository (using a
personal access token), I can't think of a way to do this safely without
exposing a privileged token to pull requests -- if you have any ideas, please
leave an issue!
### using this action with a custom commit message for fixes
By default, fixes would be have a commit message of `pre-commit fixes`.
A custom commit message can be added with the following configuration.
```yaml
- uses: pre-commit/action@v2.0.0
with:
commit_message: "Custom commit message"
```

View file

@ -8,6 +8,10 @@ inputs:
token:
description: github token to clone / push with
required: false
commit_message:
description: commit message when fixes are made
required: false
default: 'pre-commit fixes'
runs:
using: 'node12'
main: 'dist/index.js'

View file

@ -53,6 +53,7 @@ async function main() {
const cacheKey = `pre-commit-2-${hashString(py)}-${hashFile('.pre-commit-config.yaml')}`;
const restored = await cache.restoreCache(cachePaths, cacheKey);
const ret = await exec.exec('pre-commit', args, {ignoreReturnCode: push});
const commitMessage = core.getInput('commit_message');
if (!restored) {
await cache.saveCache(cachePaths, cacheKey);
}
@ -76,7 +77,7 @@ async function main() {
const branch = pr.head.ref;
await exec.exec('git', ['checkout', 'HEAD', '-b', branch]);
await exec.exec('git', ['commit', '-am', 'pre-commit fixes']);
await exec.exec('git', ['commit', '-am', commitMessage]);
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']);