mirror of
https://github.com/pre-commit/action.git
synced 2025-11-09 19:46:55 +00:00
Allow action user to use custom commit message
This commit is contained in:
parent
56c4e645ab
commit
7e5ba9a98c
3 changed files with 18 additions and 1 deletions
12
README.md
12
README.md
|
|
@ -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"
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
3
index.js
3
index.js
|
|
@ -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']);
|
||||
|
|
|
|||
Loading…
Reference in a new issue