feat: add option to customize the pushed branch
parent
9b8c94a880
commit
2a7cc0e9fb
|
@ -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-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-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-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** `preset`: Preset that is used from conventional commits. Default `angular`.
|
||||||
- **Optional** `tag-prefix`: Prefix for the git tags. Default `v`.
|
- **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.
|
- **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-on-empty: 'false'
|
||||||
skip-version-file: 'false'
|
skip-version-file: 'false'
|
||||||
skip-commit: 'false'
|
skip-commit: 'false'
|
||||||
|
git-branch: 'my-maintenance-branch'
|
||||||
```
|
```
|
||||||
|
|
||||||
No file changelog
|
No file changelog
|
||||||
|
|
|
@ -41,6 +41,11 @@ inputs:
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
|
git-branch:
|
||||||
|
description: 'The git branch to be pushed'
|
||||||
|
default: ${{ github.ref }}
|
||||||
|
required: false
|
||||||
|
|
||||||
preset:
|
preset:
|
||||||
description: 'The preset from Conventional Changelog to use'
|
description: 'The preset from Conventional Changelog to use'
|
||||||
default: 'angular'
|
default: 'angular'
|
||||||
|
|
|
@ -2,9 +2,7 @@ const core = require('@actions/core')
|
||||||
const exec = require('@actions/exec')
|
const exec = require('@actions/exec')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
|
||||||
const { GITHUB_REPOSITORY, GITHUB_REF, ENV } = process.env
|
const { GITHUB_REPOSITORY, ENV } = process.env
|
||||||
|
|
||||||
const branch = GITHUB_REF.replace('refs/heads/', '')
|
|
||||||
|
|
||||||
module.exports = new (class Git {
|
module.exports = new (class Git {
|
||||||
|
|
||||||
|
@ -122,7 +120,7 @@ module.exports = new (class Git {
|
||||||
*
|
*
|
||||||
* @return {Promise<>}
|
* @return {Promise<>}
|
||||||
*/
|
*/
|
||||||
push = () => (
|
push = (branch) => (
|
||||||
this.exec(`push origin ${branch} --follow-tags`)
|
this.exec(`push origin ${branch} --follow-tags`)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -160,7 +158,7 @@ module.exports = new (class Git {
|
||||||
/**
|
/**
|
||||||
* Validates the commands run
|
* Validates the commands run
|
||||||
*/
|
*/
|
||||||
testHistory = () => {
|
testHistory = (branch) => {
|
||||||
if (ENV === 'dont-use-git') {
|
if (ENV === 'dont-use-git') {
|
||||||
const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH, SKIPPED_PULL, SKIP_CI } = process.env
|
const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH, SKIPPED_PULL, SKIP_CI } = process.env
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ async function run() {
|
||||||
const gitUserName = core.getInput('git-user-name')
|
const gitUserName = core.getInput('git-user-name')
|
||||||
const gitUserEmail = core.getInput('git-user-email')
|
const gitUserEmail = core.getInput('git-user-email')
|
||||||
const gitPush = core.getBooleanInput('git-push')
|
const gitPush = core.getBooleanInput('git-push')
|
||||||
|
const gitBranch = core.getInput('git-branch')
|
||||||
const tagPrefix = core.getInput('tag-prefix')
|
const tagPrefix = core.getInput('tag-prefix')
|
||||||
const preset = !core.getInput('config-file-path') ? core.getInput('preset') : ''
|
const preset = !core.getInput('config-file-path') ? core.getInput('preset') : ''
|
||||||
const preCommitFile = core.getInput('pre-commit')
|
const preCommitFile = core.getInput('pre-commit')
|
||||||
|
@ -61,6 +62,7 @@ async function run() {
|
||||||
core.info(`Using "${outputFile}" as output file`)
|
core.info(`Using "${outputFile}" as output file`)
|
||||||
core.info(`Using "${conventionalConfigFile}" as config file`)
|
core.info(`Using "${conventionalConfigFile}" as config file`)
|
||||||
core.info(`Using "${gitUrl}" as gitUrl`)
|
core.info(`Using "${gitUrl}" as gitUrl`)
|
||||||
|
core.info(`Using "${gitBranch}" as gitBranch`)
|
||||||
|
|
||||||
if (preCommitFile) {
|
if (preCommitFile) {
|
||||||
core.info(`Using "${preCommitFile}" as pre-commit script`)
|
core.info(`Using "${preCommitFile}" as pre-commit script`)
|
||||||
|
@ -187,7 +189,7 @@ async function run() {
|
||||||
if (gitPush) {
|
if (gitPush) {
|
||||||
try {
|
try {
|
||||||
core.info('Push all changes')
|
core.info('Push all changes')
|
||||||
await git.push()
|
await git.push(gitBranch)
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
@ -221,7 +223,7 @@ async function run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// If we are running in test mode we use this to validate everything still runs
|
// If we are running in test mode we use this to validate everything still runs
|
||||||
git.testHistory()
|
git.testHistory(gitBranch)
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
Loading…
Reference in New Issue