Skip to content

Commit

Permalink
feat: Added create-summary option that adds the changelog as Action…
Browse files Browse the repository at this point in the history
… summary
  • Loading branch information
TriPSs committed May 27, 2022
1 parent ae32d56 commit 38e51f4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,6 +3,7 @@

# Editors
.vscode
.idea

# Logs
logs
Expand Down
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -24,13 +24,14 @@ This action will bump version, tag commit and generate a changelog with conventi
- **Optional** `fallback-version`: The fallback version, if no older one can be detected, or if it is the first one. Default `'0.1.0'`
- **Optional** `config-file-path`: Path to the conventional changelog config file. If set, the preset setting will be ignored
- **Optional** `pre-changelog-generation`: Path to the pre-changelog-generation script file. No hook by default.
- **Optional** `skip-ci`: Adds instruction to github to not consider the push something to rebuild. Default `true`.
- **Optional** `skip-ci`: Adds instruction to Github to not consider the push something to rebuild. Default `true`.
- **Optional** `create-summary`: Adds the generated changelog as Action Summary. Default `false`.

### Pre-Commit hook

> Function in a specified file will be run right before the git-add-git-commit phase, when the next
> version is already known and a new changelog has been generated. You can run any chores across your
> repository that should be added and commited with the release commit.
> repository that should be added and committed with the release commit.
Specified path could be relative or absolute. If it is relative, then it will be based on the `GITHUB_WORKSPACE` path.

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Expand Up @@ -118,6 +118,11 @@ inputs:
default: 'true'
required: false

create-summary:
description: 'Adds the generated changelog as Action Summary'
default: 'false'
required: false

outputs:
changelog:
description: 'The generated changelog for the new version'
Expand Down
14 changes: 13 additions & 1 deletion src/index.js
Expand Up @@ -44,9 +44,10 @@ async function run() {
const preChangelogGenerationFile = core.getInput('pre-changelog-generation')
const gitUrl = core.getInput('git-url')
const skipCi = core.getBooleanInput('skip-ci')
const createSummary = core.getBooleanInput('create-summary')

if (skipCi) {
gitCommitMessage += " [skip ci]"
gitCommitMessage += ' [skip ci]'
}

core.info(`Using "${preset}" preset`)
Expand Down Expand Up @@ -207,6 +208,17 @@ async function run() {
core.setOutput('tag', gitTag)
core.setOutput('skipped', 'false')

if (createSummary) {
try {
await core.summary
.addHeading(gitTag, 2)
.addRaw(cleanChangelog)
.write()
} catch (err) {
core.warning(`Was unable to create summary! Error: "${err}"`,)
}
}

try {
// If we are running in test mode we use this to validate everything still runs
git.testHistory()
Expand Down

0 comments on commit 38e51f4

Please sign in to comment.