Skip to content
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
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ The action comes with additional options that you can use to configure your proj
| 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 |
| docker_context_path | false | Path to use as build context (defaults to Dockerfile dir). This option only makes sense when usedocker enabled. | ./src, ./backend |
| docker_find_recursive | false | Pushes Dockerfile.<process> found in current and subdirectories. This option only makes sense when usedocker enabled. | true or false |
| appdir | false | Set if your app is located in a subdirectory | api, apis/python |
| healthcheck | false | A URL to which a healthcheck is performed (checks for 200 request) | https://demo-rest-api.herokuapp.com |
| checkstring | false | Value to check for when conducting healthcheck requests | ok |
Expand Down Expand Up @@ -182,6 +184,73 @@ jobs:

Also, thanks to [Olav Sundfør](https://github.com/olaven) for adding the Docker feature and [Matt Stavola](https://github.com/mbStavola) for adding the ability to pass in build args.

#### Deploy with Docker Context Path

If your Dockerfile is not located in the root directory or you need to specify a custom build context (the root in case of a monorepo), you can use the `docker_context_path` option:

_.github/workflows/main.yml_

```yaml
name: Deploy

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Heroku CLI
run: |
curl https://cli-assets.heroku.com/install.sh | sh
- uses: akhileshns/[email protected]
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "YOUR APP's NAME"
heroku_email: "YOUR EMAIL"
usedocker: true
docker_context_path: "."
docker_find_recursive: true
docker_heroku_process_type: "worker" # Specify the process type if needed
```

#### Deploy with Multiple Docker Processes (Recursive)

To deploy multiple Docker containers from different subdirectories (using `Dockerfile.web`, `Dockerfile.worker`, etc.), use the `docker_find_recursive` option:

_.github/workflows/main.yml_

```yaml
name: Deploy

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Heroku CLI
run: |
curl https://cli-assets.heroku.com/install.sh | sh
- uses: akhileshns/[email protected]
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "YOUR APP's NAME"
heroku_email: "YOUR EMAIL"
usedocker: true
docker_find_recursive: true
docker_heroku_process_type: "web worker"
```

This will look for `Dockerfile.web` and `Dockerfile.worker` in the current directory and subdirectories.

### Deploy with custom Buildpacks

Taken from the official heroku website:
Expand Down Expand Up @@ -679,6 +748,8 @@ jobs:

- For more info on how Heroku enables deployment using Docker, check out [https://www.heroku.com/deploy-with-docker](https://www.heroku.com/deploy-with-docker)

- For more information about Docker container deployment options, including `docker_context_path` and `docker_find_recursive`, see the [Heroku Container Registry & Runtime documentation](https://devcenter.heroku.com/articles/container-registry-and-runtime)

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/AkhileshNS/heroku-deploy/blob/master/LICENSE) file for details
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ inputs:
docker_build_args:
description: "A list of args to pass into the Docker build. This option only makes sense when usedocker enabled"
required: false
docker_context_path:
description: "Path to use as build context (defaults to Dockerfile dir). This option only makes sense when usedocker enabled"
required: false
default: ""
docker_find_recursive:
description: "Pushes Dockerfile.<process> found in current and subdirectories. This option only makes sense when usedocker enabled"
required: false
default: "false"
appdir:
description: "Set if your app is located in a subdirectory."
default: ""
Expand Down
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,17 @@ const deploy = ({
usedocker,
dockerHerokuProcessType,
dockerBuildArgs,
dockerContextPath,
dockerFindRecursive,
appdir,
}) => {
const force = !dontuseforce ? "--force" : "";
if (usedocker) {
const recursiveFlag = dockerFindRecursive ? "--recursive" : "";
const contextPathFlag = dockerContextPath ? `--context-path ${dockerContextPath}` : "";

execSync(
`heroku container:push ${dockerHerokuProcessType} --app ${app_name} ${dockerBuildArgs}`,
`heroku container:push ${dockerHerokuProcessType} --app ${app_name} ${dockerBuildArgs} ${recursiveFlag} ${contextPathFlag}`.trim().replace(/\s+/g, ' '),
appdir ? { cwd: appdir } : null
);
execSync(
Expand Down Expand Up @@ -146,6 +151,8 @@ let heroku = {
usedocker: core.getInput("usedocker") === "false" ? false : true,
dockerHerokuProcessType: core.getInput("docker_heroku_process_type"),
dockerBuildArgs: core.getInput("docker_build_args"),
dockerContextPath: core.getInput("docker_context_path"),
dockerFindRecursive: core.getInput("docker_find_recursive") === "false" ? false : true,
appdir: core.getInput("appdir"),
healthcheck: core.getInput("healthcheck"),
checkstring: core.getInput("checkstring"),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "heroku-deploy",
"version": "3.13.15",
"version": "3.13.16",
"description": "A simple github action that dynamically deploys an app to heroku",
"main": "index.js",
"scripts": {
Expand Down