Skip to content

Commit

Permalink
Merge pull request #211 from dnlcrl/master
Browse files Browse the repository at this point in the history
Feature: check-last-commit-only option
  • Loading branch information
phips28 authored May 12, 2023
2 parents 25cd8ff + 23b3999 commit f1eec0f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ Example:
bump-policy: 'ignore'
```

#### **check-last-commit-only:**

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** Set false you want to avoid pushing the new version tag/package.json. Example:
```yaml
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ inputs:
description: 'Set version bump ignore policy'
default: 'all'
required: false
check-last-commit-only:
description: 'Check only last commit message'
default: 'false'
required: false
push:
description: '[DEPRECATED] Set to false to skip pushing the new tag'
default: 'true'
Expand Down
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ const pkg = getPackageJson();
const tagSuffix = process.env['INPUT_TAG-SUFFIX'] || '';
console.log('tagPrefix:', tagPrefix);
console.log('tagSuffix:', tagSuffix);
const messages = event.commits ? event.commits.map((commit) => commit.message + '\n' + commit.body) : [];

const checkLastCommitOnly = process.env['INPUT_CHECK-LAST-COMMIT-ONLY'] || 'false';

let messages = []
if (checkLastCommitOnly === 'true') {
console.log('Only checking the last commit...');
const commit = event.commits && event.commits.lengths > 0 ? event.commits[event.commits.length - 1] : null;
messages = commit ? [commit.message + '\n' + commit.body] : [];
} else {
messages = event.commits ? event.commits.map((commit) => commit.message + '\n' + commit.body) : [];
}

const commitMessage = process.env['INPUT_COMMIT-MESSAGE'] || 'ci: version bump to {{version}}';
console.log('commit messages:', messages);
Expand Down

0 comments on commit f1eec0f

Please sign in to comment.