diff --git a/action.yml b/action.yml index d61198d8..5e4f9135 100644 --- a/action.yml +++ b/action.yml @@ -55,6 +55,10 @@ inputs: description: | Skips creating a Pull Request and pushes directly to the default branch. Defaults to false required: false + BRANCH_PREFIX: + description: | + Specify a different prefix for the new branch in the target repo. Defaults to repo-sync/SOURCE_REPO_NAME + required: false runs: using: 'node12' diff --git a/src/config.js b/src/config.js index 083284eb..9dfb5b37 100644 --- a/src/config.js +++ b/src/config.js @@ -95,6 +95,10 @@ const context = { key: 'SKIP_PR', type: 'boolean', default: false + }), + BRANCH_PREFIX: getVar({ + key: 'BRANCH_PREFIX', + default: 'repo-sync/SOURCE_REPO_NAME' }) } diff --git a/src/git.js b/src/git.js index c421b748..97d7c1cd 100644 --- a/src/git.js +++ b/src/git.js @@ -9,7 +9,8 @@ const { TMP_DIR, COMMIT_PREFIX, GITHUB_REPOSITORY, - OVERWRITE_EXISTING_PR + OVERWRITE_EXISTING_PR, + BRANCH_PREFIX } = require('./config') const { dedent, execCmd } = require('./helpers') @@ -58,7 +59,9 @@ const init = (repo) => { } const createPrBranch = async () => { - let newBranch = `repo-sync/${ GITHUB_REPOSITORY.split('/')[1] }/${ repo.branch }` + const prefix = BRANCH_PREFIX.replace('SOURCE_REPO_NAME', GITHUB_REPOSITORY.split('/')[1]) + + let newBranch = path.join(prefix, repo.branch) if (OVERWRITE_EXISTING_PR === false) { newBranch += `-${ Math.round((new Date()).getTime() / 1000) }`