diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 916f0a7..187f7d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -91,3 +91,26 @@ jobs: checkstring: "ok" procfile: "web: gunicorn index:app" - run: npm run test-action https://akhileshns-hd-test-4.herokuapp.com/ + + deploy-test-5: + runs-on: ubuntu-latest + needs: deploy-test-2 + steps: + - uses: actions/checkout@v2 + - run: npm run setup tests/test-3/data.json + - run: | + git config --global user.email "nsakhilesh02@gmail.com" + git config --global user.name "AkhileshNS" + git add -A + git commit -m "Added data.json" + - uses: akhileshns/heroku-deploy@master + with: + heroku_api_key: ${{secrets.HEROKU_API_KEY}} + heroku_app_name: "akhileshns-hd-test-3" + heroku_email: "nsakhilesh02@gmail.com" + appdir: "tests/test-5" + usedocker: true + dockerHerokuPushRecursive: true + dockerHerokuProcessType: web + healthcheck: "https://akhileshns-hd-test-3.herokuapp.com/" + - run: npm run test-action https://akhileshns-hd-test-3.herokuapp.com/ \ No newline at end of file diff --git a/README.md b/README.md index 9bdc59c..8290370 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ The action comes with additional options that you can use to configure your proj | 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 | | 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_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 | | 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 | | healthcheck | false | A URL to which a healthcheck is performed (checks for 200 request) | https://demo-rest-api.herokuapp.com | diff --git a/action.yml b/action.yml index a7c909e..0f6abde 100644 --- a/action.yml +++ b/action.yml @@ -36,6 +36,10 @@ inputs: description: "Type of heroku process (web, worker, etc). This option only makes sense when usedocker enabled" default: "web" required: false + docker_heroku_push_recursive: + description: "To push one or all dedicated process type Dockerfiles e.g. `Dockerfile.web` for web. This option only makes sense when usedocker enabled" + default: "false" + required: false docker_build_args: description: "A list of args to pass into the Docker build. This option only makes sense when usedocker enabled" required: false diff --git a/index.js b/index.js index 3244d0c..9c989ea 100644 --- a/index.js +++ b/index.js @@ -70,12 +70,14 @@ const deploy = ({ usedocker, dockerHerokuProcessType, dockerBuildArgs, + dockerHerokuPushRecursive, appdir, }) => { const force = !dontuseforce ? "--force" : ""; if (usedocker) { + const push_recursive = dockerHerokuPushRecursive ? "--recursive" : ""; execSync( - `heroku container:push ${dockerHerokuProcessType} --app ${app_name} ${dockerBuildArgs}`, + `heroku container:push ${push_recursive} ${dockerHerokuProcessType} --app ${app_name} ${dockerBuildArgs}`, appdir ? { cwd: appdir } : null ); execSync( @@ -138,6 +140,7 @@ let heroku = { dontautocreate: core.getInput("dontautocreate") === "false" ? false : true, usedocker: core.getInput("usedocker") === "false" ? false : true, dockerHerokuProcessType: core.getInput("docker_heroku_process_type"), + dockerHerokuPushRecursive: core.getInput("docker_heroku_push_recursive") === "false" ? false : true, dockerBuildArgs: core.getInput("docker_build_args"), appdir: core.getInput("appdir"), healthcheck: core.getInput("healthcheck"), diff --git a/tests/test-5/Dockerfile.web b/tests/test-5/Dockerfile.web new file mode 100644 index 0000000..60c4ef7 --- /dev/null +++ b/tests/test-5/Dockerfile.web @@ -0,0 +1,12 @@ +FROM python:3.8.2-alpine3.11 + +WORKDIR /usr/src/app + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 8080 + +CMD [ "python", "./index.py" ] \ No newline at end of file diff --git a/tests/test-5/data.json b/tests/test-5/data.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/test-5/data.json @@ -0,0 +1 @@ +{} diff --git a/tests/test-5/index.py b/tests/test-5/index.py new file mode 100644 index 0000000..b0d51ae --- /dev/null +++ b/tests/test-5/index.py @@ -0,0 +1,13 @@ +# IMPORTS +import os +from flask import Flask +app = Flask(__name__) +port = int(os.environ.get("PORT", 8080)) + +@app.route('/') +def hello_handler(): + f = open("data.json"); + return f.read() + +if __name__ == '__main__': + app.run(debug=True, host='0.0.0.0', port=port) diff --git a/tests/test-5/requirements.txt b/tests/test-5/requirements.txt new file mode 100644 index 0000000..b1a74eb --- /dev/null +++ b/tests/test-5/requirements.txt @@ -0,0 +1,9 @@ +autopep8==1.4.4 +Click==7.0 +Flask==1.1.1 +gunicorn==19.10.0 +itsdangerous==1.1.0 +Jinja2==2.10.3 +MarkupSafe==1.1.1 +pycodestyle==2.5.0 +Werkzeug==0.16.0 \ No newline at end of file