add check-last-commit-only to check only in last commit

This commit is contained in:
dnlcrl 2023-05-12 09:09:57 +02:00
parent 25cd8ffb8e
commit cec8375d0a
3 changed files with 30 additions and 0 deletions

View File

@ -204,6 +204,19 @@ Example:
bump-policy: 'ignore' bump-policy: 'ignore'
``` ```
### **check-only-last-commit**
Set check-last-commit-only to only read last commit's message (optional). Example:
```yaml
- name: 'Automated Version Bump'
uses: 'phips28/gh-action-bump-version@master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
check-last-commit-only: 'true'
```
#### [DEPRECATED] **push:** #### [DEPRECATED] **push:**
**DEPRECATED** Set false you want to avoid pushing the new version tag/package.json. Example: **DEPRECATED** Set false you want to avoid pushing the new version tag/package.json. Example:
```yaml ```yaml

View File

@ -70,6 +70,10 @@ inputs:
description: 'Set version bump ignore policy' description: 'Set version bump ignore policy'
default: 'all' default: 'all'
required: false required: false
check-last-commit-only:
description: 'Check only last commit's message'
default: 'false'
required: false
push: push:
description: '[DEPRECATED] Set to false to skip pushing the new tag' description: '[DEPRECATED] Set to false to skip pushing the new tag'
default: 'true' default: 'true'

View File

@ -35,6 +35,19 @@ const pkg = getPackageJson();
const tagSuffix = process.env['INPUT_TAG-SUFFIX'] || ''; const tagSuffix = process.env['INPUT_TAG-SUFFIX'] || '';
console.log('tagPrefix:', tagPrefix); console.log('tagPrefix:', tagPrefix);
console.log('tagSuffix:', tagSuffix); console.log('tagSuffix:', tagSuffix);
const checkLAstCommitOnly = process.env['INPUT_CHECK-LAST-COMMIT-ONLY'] || 'false';
if (checkLAstCommitOnly === 'true') {
console.log('Only checking the last commit...');
const commit = event.commits ? event.commits[event.commits.length - 1] : null;
const messages = commit ? [commit.message + '\n' + commit.body] : [];
await run(messages, versionType, tagPrefix, tagSuffix, pkg);
} else {
const messages = event.commits ? event.commits.map((commit) => commit.message + '\n' + commit.body) : [];
await run(messages, versionType, tagPrefix, tagSuffix, pkg);
}
const messages = event.commits ? event.commits.map((commit) => commit.message + '\n' + commit.body) : []; const messages = event.commits ? event.commits.map((commit) => commit.message + '\n' + commit.body) : [];
const commitMessage = process.env['INPUT_COMMIT-MESSAGE'] || 'ci: version bump to {{version}}'; const commitMessage = process.env['INPUT_COMMIT-MESSAGE'] || 'ci: version bump to {{version}}';