diff --git a/README.md b/README.md index ce50955..5400ca3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This action will bump version, tag commit and generate a changelog with conventi - **Optional** `git-user-email`: The git user.email to use for the commit. Default `conventional.changelog.action@github.com` - **Optional** `git-pull-method`: The git pull method used when pulling all changes from remote. Default `--ff-only` - **Optional** `git-push`: Push all the GIT changes. Default `true` +- **Optional** `git-branch`: The branch used to push. Default is the current branch (`${{ github.ref }}`) - **Optional** `preset`: Preset that is used from conventional commits. Default `angular`. - **Optional** `tag-prefix`: Prefix for the git tags. Default `v`. - **Optional** `output-file`: File to output the changelog to. Default `CHANGELOG.md`, when providing `'false'` no file will be generated / updated. @@ -129,6 +130,7 @@ Overwrite everything skip-on-empty: 'false' skip-version-file: 'false' skip-commit: 'false' + git-branch: 'my-maintenance-branch' ``` No file changelog diff --git a/action.yml b/action.yml index 5e02fc0..35b85de 100644 --- a/action.yml +++ b/action.yml @@ -41,6 +41,11 @@ inputs: default: 'true' required: false + git-branch: + description: 'The git branch to be pushed' + default: ${{ github.ref }} + required: false + preset: description: 'The preset from Conventional Changelog to use' default: 'angular' diff --git a/src/helpers/git.js b/src/helpers/git.js index eee8a0d..1fcc10a 100644 --- a/src/helpers/git.js +++ b/src/helpers/git.js @@ -2,9 +2,7 @@ const core = require('@actions/core') const exec = require('@actions/exec') const assert = require('assert') -const { GITHUB_REPOSITORY, GITHUB_REF, ENV } = process.env - -const branch = GITHUB_REF.replace('refs/heads/', '') +const { GITHUB_REPOSITORY, ENV } = process.env module.exports = new (class Git { @@ -122,7 +120,7 @@ module.exports = new (class Git { * * @return {Promise<>} */ - push = () => ( + push = (branch) => ( this.exec(`push origin ${branch} --follow-tags`) ) @@ -160,7 +158,7 @@ module.exports = new (class Git { /** * Validates the commands run */ - testHistory = () => { + testHistory = (branch) => { if (ENV === 'dont-use-git') { const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH, SKIPPED_PULL, SKIP_CI } = process.env diff --git a/src/index.js b/src/index.js index fcfcb12..78e86e0 100644 --- a/src/index.js +++ b/src/index.js @@ -29,6 +29,7 @@ async function run() { const gitUserName = core.getInput('git-user-name') const gitUserEmail = core.getInput('git-user-email') const gitPush = core.getBooleanInput('git-push') + const gitBranch = core.getInput('git-branch') const tagPrefix = core.getInput('tag-prefix') const preset = !core.getInput('config-file-path') ? core.getInput('preset') : '' const preCommitFile = core.getInput('pre-commit') @@ -61,6 +62,7 @@ async function run() { core.info(`Using "${outputFile}" as output file`) core.info(`Using "${conventionalConfigFile}" as config file`) core.info(`Using "${gitUrl}" as gitUrl`) + core.info(`Using "${gitBranch}" as gitBranch`) if (preCommitFile) { core.info(`Using "${preCommitFile}" as pre-commit script`) @@ -187,7 +189,7 @@ async function run() { if (gitPush) { try { core.info('Push all changes') - await git.push() + await git.push(gitBranch) } catch (error) { console.error(error) @@ -221,7 +223,7 @@ async function run() { try { // If we are running in test mode we use this to validate everything still runs - git.testHistory() + git.testHistory(gitBranch) } catch (error) { console.error(error)