Skip to content

Commit bdf88de

Browse files
author
Jan Zaydowicz
committed
feat: add recursive heroku docker pushes
this allows to build dedicated production images for each heroku process type. Additionally with this change multiple images can be deployed at once.
1 parent d81c270 commit bdf88de

File tree

8 files changed

+67
-1
lines changed

8 files changed

+67
-1
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,26 @@ jobs:
9191
checkstring: "ok"
9292
procfile: "web: gunicorn index:app"
9393
- run: npm run test-action https://akhileshns-hd-test-4.herokuapp.com/
94+
95+
deploy-test-5:
96+
runs-on: ubuntu-latest
97+
needs: deploy-test-2
98+
steps:
99+
- uses: actions/checkout@v2
100+
- run: npm run setup tests/test-3/data.json
101+
- run: |
102+
git config --global user.email "[email protected]"
103+
git config --global user.name "AkhileshNS"
104+
git add -A
105+
git commit -m "Added data.json"
106+
- uses: akhileshns/heroku-deploy@master
107+
with:
108+
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
109+
heroku_app_name: "akhileshns-hd-test-3"
110+
heroku_email: "[email protected]"
111+
appdir: "tests/test-5"
112+
usedocker: true
113+
dockerHerokuPushRecursive: true
114+
dockerHerokuProcessType: web
115+
healthcheck: "https://akhileshns-hd-test-3.herokuapp.com/"
116+
- run: npm run test-action https://akhileshns-hd-test-3.herokuapp.com/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ The action comes with additional options that you can use to configure your proj
8989
| dontuseforce | false | Set this to true if you don't want to use --force when switching branches | true or false |
9090
| usedocker | false | Will deploy using Dockerfile in project root | true or false |
9191
| 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 |
92+
| docker_heroku_push_recursive | false | "To push one or all dedicated process type Dockerfiles e.g. `Dockerfile.web` for web. Futher usage information can be found [in the docs](https://devcenter.heroku.com/changelog-items/1191) This option only makes sense when usedocker enabled" | true or false |
9293
| docker_build_args | false | A list of args to pass into the Docker build. This option only makes sense when usedocker enabled. | NODE_ENV |
9394
| appdir | false | Set if your app is located in a subdirectory | api, apis/python |
9495
| healthcheck | false | A URL to which a healthcheck is performed (checks for 200 request) | https://demo-rest-api.herokuapp.com |

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ inputs:
3636
description: "Type of heroku process (web, worker, etc). This option only makes sense when usedocker enabled"
3737
default: "web"
3838
required: false
39+
docker_heroku_push_recursive:
40+
description: "To push one or all dedicated process type Dockerfiles e.g. `Dockerfile.web` for web. This option only makes sense when usedocker enabled"
41+
default: "false"
42+
required: false
3943
docker_build_args:
4044
description: "A list of args to pass into the Docker build. This option only makes sense when usedocker enabled"
4145
required: false

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ const deploy = ({
7070
usedocker,
7171
dockerHerokuProcessType,
7272
dockerBuildArgs,
73+
dockerHerokuPushRecursive,
7374
appdir,
7475
}) => {
7576
const force = !dontuseforce ? "--force" : "";
7677
if (usedocker) {
78+
const push_recursive = dockerHerokuPushRecursive ? "--recursive" : "";
7779
execSync(
78-
`heroku container:push ${dockerHerokuProcessType} --app ${app_name} ${dockerBuildArgs}`,
80+
`heroku container:push ${push_recursive} ${dockerHerokuProcessType} --app ${app_name} ${dockerBuildArgs}`,
7981
appdir ? { cwd: appdir } : null
8082
);
8183
execSync(
@@ -138,6 +140,7 @@ let heroku = {
138140
dontautocreate: core.getInput("dontautocreate") === "false" ? false : true,
139141
usedocker: core.getInput("usedocker") === "false" ? false : true,
140142
dockerHerokuProcessType: core.getInput("docker_heroku_process_type"),
143+
dockerHerokuPushRecursive: core.getInput("docker_heroku_push_recursive") === "false" ? false : true,
141144
dockerBuildArgs: core.getInput("docker_build_args"),
142145
appdir: core.getInput("appdir"),
143146
healthcheck: core.getInput("healthcheck"),

tests/test-5/Dockerfile.web

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.8.2-alpine3.11
2+
3+
WORKDIR /usr/src/app
4+
5+
COPY requirements.txt ./
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY . .
9+
10+
EXPOSE 8080
11+
12+
CMD [ "python", "./index.py" ]

tests/test-5/data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

tests/test-5/index.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# IMPORTS
2+
import os
3+
from flask import Flask
4+
app = Flask(__name__)
5+
port = int(os.environ.get("PORT", 8080))
6+
7+
@app.route('/')
8+
def hello_handler():
9+
f = open("data.json");
10+
return f.read()
11+
12+
if __name__ == '__main__':
13+
app.run(debug=True, host='0.0.0.0', port=port)

tests/test-5/requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
autopep8==1.4.4
2+
Click==7.0
3+
Flask==1.1.1
4+
gunicorn==19.10.0
5+
itsdangerous==1.1.0
6+
Jinja2==2.10.3
7+
MarkupSafe==1.1.1
8+
pycodestyle==2.5.0
9+
Werkzeug==0.16.0

0 commit comments

Comments
 (0)