diff --git a/README.md b/README.md index 94843ce..c04d3da 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ The action comes with additional options that you can use to configure your proj | branch | false | The branch that you would like to deploy to Heroku. Defaults to "HEAD" | master, dev, test | | dontautocreate | false | Set this to true if you don't want to automatically create the Heroku app | true or false | | dontuseforce | false | Set this to true if you don't want to use --force when switching branches | true or false | +| useforce | false | Set this to true if you want to use --force when switching branches | true or false | | usedocker | false | Will deploy using Dockerfile in project root | true or false | | docker_heroku_process_type | false | Type of heroku process (web, worker, etc). This option only makes sense when usedocker enabled. Defaults to "web" (Thanks to [singleton11](https://github.com/singleton11) for adding this feature) | web, worker | | docker_build_args | false | A list of args to pass into the Docker build. This option only makes sense when usedocker enabled. | NODE_ENV | diff --git a/action.yml b/action.yml index a7c909e..6267349 100644 --- a/action.yml +++ b/action.yml @@ -24,6 +24,10 @@ inputs: description: "Set this to true if you don't want to use --force when switching branches" default: "false" required: false + useforce: + description: "Set this to true if you want to use --force when switching branches" + default: "false" + required: false dontautocreate: description: "Set this to true if you don't want to automatically create the Heroku app" default: "false" diff --git a/index.js b/index.js index 2f5bee2..bbe4f9f 100644 --- a/index.js +++ b/index.js @@ -135,6 +135,7 @@ let heroku = { buildpack: core.getInput("buildpack"), branch: core.getInput("branch"), dontuseforce: core.getInput("dontuseforce") === "false" ? false : true, + useforce: core.getInput("useforce") === "true" ? true : false, dontautocreate: core.getInput("dontautocreate") === "false" ? false : true, usedocker: core.getInput("usedocker") === "false" ? false : true, dockerHerokuProcessType: core.getInput("docker_heroku_process_type"), @@ -221,7 +222,7 @@ if (heroku.dockerBuildArgs) { addConfig(heroku); try { - deploy({ ...heroku, dontuseforce: true }); + deploy({ ...heroku, dontuseforce: !heroku.useforce }); } catch (err) { console.error(` Unable to push branch because the branch is behind the deployed branch. Using --force to deploy branch. @@ -229,7 +230,9 @@ if (heroku.dockerBuildArgs) { Specifically, the error was: ${err} `); - deploy(heroku); + if (!heroku.useforce && !heroku.dontuseforce) { + deploy(heroku); + } } if (heroku.healthcheck) {