Skip to content

Commit

Permalink
Merge pull request #60 from Dhina17/master
Browse files Browse the repository at this point in the history
Add remote_branch option and increase the childProcess.execSync buffer size
  • Loading branch information
AkhileshNS committed Jan 31, 2021
2 parents fb6a39f + 0c20baf commit fd6b366
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ The action comes with additional options that you can use to configure your proj
| justlogin | false | Set to true if you want the action to just login to Heroku and nothing else | true or false |
| region | false | The region in which you would like to deploy a server | eu or dublin |
| team | false | If deploying to an organization, then specify the name of the team or organization here | team-xyz |
| remote_branch | false | The remote branch to which you would like to push | main |
## Examples
Expand Down Expand Up @@ -241,6 +242,35 @@ jobs:

Though this is also possible to do with GitHub Actions, click [here](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on) for more information

### Deploy custom remote branch

You can use the **remote_branch** option to deploy an app to another remote branch

_.github/workflows/main.yml_

```yaml
name: Deploy
on:
push:
branches:
- master # Changing the branch here would also work
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.8.9 # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "YOUR APP's NAME" #Must be unique in Heroku
heroku_email: "YOUR EMAIL"
remote_branch: "main"
```

Though this is also possible to do with GitHub Actions, click [here](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on) for more information

## Health Check

Sometimes you will run into issues where the action has successfully deployed the project but because of some error in code or the like, the Heroku App crashes or fails to launch. To counter this, you can setup a healthcheck in the action:
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ inputs:
description: "If deploying to an organization, then specify the name of the team or organization here"
required: false
default: ""
remote_branch:
description: "The remote branch to which you would like to push"
required: false
default: "master"
outputs:
status:
description: "The Success/Failure of the action"
Expand Down
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const deploy = ({
dockerHerokuProcessType,
dockerBuildArgs,
appdir,
remote_branch,
}) => {
const force = !dontuseforce ? "--force" : "";
if (usedocker) {
Expand All @@ -82,11 +83,15 @@ const deploy = ({
appdir ? { cwd: appdir } : null
);
} else {
// Fetch before pushing
execSync(`git fetch heroku ${remote_branch}`);
// Push
if (appdir === "") {
execSync(`git push heroku ${branch}:refs/heads/master ${force}`);
execSync(`git push heroku ${branch}:refs/heads/${remote_branch} ${force}`, {maxBuffer: 104857600});
} else {
execSync(
`git push ${force} heroku \`git subtree split --prefix=${appdir} ${branch}\`:refs/heads/master`
`git push ${force} heroku \`git subtree split --prefix=${appdir} ${branch}\`:refs/heads/${remote_branch}`,
{maxBuffer: 104857600}
);
}
}
Expand Down Expand Up @@ -135,6 +140,7 @@ let heroku = {
justlogin: core.getInput("justlogin") === "false" ? false : true,
region: core.getInput("region"),
team: core.getInput("team"),
remote_branch: core.getInput("remote_branch"),
};

// Formatting
Expand Down

0 comments on commit fd6b366

Please sign in to comment.