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

Add recursive and context-path options #88

Open
wants to merge 2 commits 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
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ The action comes with additional options that you can use to configure your proj
| 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 |
| usedocker | false | Will deploy using Dockerfile in project root | true or false |
| context_path | false | Set if you want to set path to use as build context (defaults to Dockerfile dir) | ., api |
| userecursive | false | Set this to true if you want to use --recursive for pushes Dockerfile.process found in current and subdirectories | 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 |
| appdir | false | Set if your app is located in a subdirectory | api, apis/python |
Expand Down Expand Up @@ -164,6 +166,33 @@ jobs:
SECRET_KEY: ${{ secrets.MY_SECRET_KEY }}
```

You can use `userecursive` and `context_path` options if your Dockerfile is located in a subdirectory. Heroku will search for Dockerfile in current and subdirectories then build at the context path.

_.github/workflows/main.yml_

```yaml
name: Deploy

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected] # 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"
usedocker: true
userecursive: true
context_path: "."
```

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 custom Buildpacks
Expand Down
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
userecursive:
description: "Set this to true if you want to use --recursive for pushes Dockerfile.<process> found in current and subdirectories"
default: "false"
required: false
context_path:
description: "Set if you want to set path to use as build context (defaults to Dockerfile dir)"
default: ""
required: false
appdir:
description: "Set if your app is located in a subdirectory."
default: ""
Expand Down
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,17 @@ const deploy = ({
dockerHerokuProcessType,
dockerBuildArgs,
appdir,
userecursive,
context_path,
}) => {
const force = !dontuseforce ? "--force" : "";
if (usedocker) {
execSync(
`heroku container:push ${dockerHerokuProcessType} --app ${app_name} ${dockerBuildArgs}`,
`heroku container:push ${dockerHerokuProcessType} ${
userecursive ? "--recursive" : null
} ${
context_path ? `--context-path ${context_path}` : null
} --app ${app_name} ${dockerBuildArgs}`,
appdir ? { cwd: appdir } : null
);
execSync(
Expand Down Expand Up @@ -151,6 +157,8 @@ let heroku = {
region: core.getInput("region"),
stack: core.getInput("stack"),
team: core.getInput("team"),
userecursive: core.getInput("userecursive") === "false" ? false : true,
context_path: core.getInput("context_path"),
};

// Formatting
Expand Down