Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#119 Add "useforce" argument to enforce usage of --force #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -221,15 +222,17 @@ 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.
(If you want to avoid this, set dontuseforce to 1 in with: of .github/workflows/action.yml.
Specifically, the error was: ${err}
`);

deploy(heroku);
if (!heroku.useforce && !heroku.dontuseforce) {
deploy(heroku);
}
}

if (heroku.healthcheck) {
Expand Down