From 10571c76ffeb9e7186ec2aa09c968b13efbbb5a7 Mon Sep 17 00:00:00 2001 From: Joseph Manley Date: Sun, 4 Oct 2020 18:14:24 -0400 Subject: [PATCH] Intial project --- .github/workflows/test_action.yml | 19 ++++ Dockerfile | 14 +++ action.yml | 19 ++++ entrypoint.sh | 30 +++++++ test_project/.gitignore | 138 ++++++++++++++++++++++++++++++ test_project/requirements.txt | 2 + test_project/test/__init__.py | 11 +++ test_project/zappa_settings.yaml | 7 ++ 8 files changed, 240 insertions(+) create mode 100644 .github/workflows/test_action.yml create mode 100644 Dockerfile create mode 100644 action.yml create mode 100644 entrypoint.sh create mode 100644 test_project/.gitignore create mode 100644 test_project/requirements.txt create mode 100644 test_project/test/__init__.py create mode 100644 test_project/zappa_settings.yaml diff --git a/.github/workflows/test_action.yml b/.github/workflows/test_action.yml new file mode 100644 index 0000000..e2a4d81 --- /dev/null +++ b/.github/workflows/test_action.yml @@ -0,0 +1,19 @@ +name: Test Action + +on: [push, pull_request, workflow_dispatch] + +jobs: + TestAction: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Run Action + uses: ./ + with: + directory: test_project + environment: test + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-1 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..100b218 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM amazon/aws-cli:latest + +LABEL "com.github.actions.name"="Zappa Deploy" +LABEL "com.github.actions.description"="Deploys a Zappa application to AWS" +LABEL "com.github.actions.icon"="package" +LABEL "com.github.actions.color"="blue" + +LABEL repository="https://github.com/josephbmanley/zappa-deploy-action" +LABEL maintainer="Joseph Manley " + +USER root +ADD entrypoint.sh /entrypoint.sh +RUN chmod +x entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..e495560 --- /dev/null +++ b/action.yml @@ -0,0 +1,19 @@ +name: "Zappa Deploy" +description: "Deploys a Zappa application to AWS" +author: josephbmanley +inputs: + directory: + description: "" + default: "." + environment: + description: 'Name of the preset in `zappa_settings` to use' + required: true +runs: + using: docker + image: Dockerfile + args: + - ${{ inputs.directory }} + - ${{ inputs.environment }} +branding: + icon: package + color: blue \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..380ff5a --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -e + +# Move to project directory +cd $1 + +# Install virtual environment +pip install virtualenv +virtualenv .venv +source ./.venv/bin/activate + +# Install Zappa +pip install zappa + +# Install requirements +pip install -r requirements.txt + +{ + # Check status (whether to update or deploy) + zappa status $2 + + # Update environment + echo "Starting update..." + zappa update $2 +} || { + # Deploy environment + echo "Starting deployment..." + zappa deploy $2 + +} \ No newline at end of file diff --git a/test_project/.gitignore b/test_project/.gitignore new file mode 100644 index 0000000..a81c8ee --- /dev/null +++ b/test_project/.gitignore @@ -0,0 +1,138 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ diff --git a/test_project/requirements.txt b/test_project/requirements.txt new file mode 100644 index 0000000..f37e240 --- /dev/null +++ b/test_project/requirements.txt @@ -0,0 +1,2 @@ +zappa +flask \ No newline at end of file diff --git a/test_project/test/__init__.py b/test_project/test/__init__.py new file mode 100644 index 0000000..4254267 --- /dev/null +++ b/test_project/test/__init__.py @@ -0,0 +1,11 @@ +from flask import Flask + +app = Flask(__name__) +app.secret_key = "test" + +@app.route("/") +def index(): + return "Hello World!" + +if __name__ == '__main__': + app.run(debug=True,host='0.0.0.0') \ No newline at end of file diff --git a/test_project/zappa_settings.yaml b/test_project/zappa_settings.yaml new file mode 100644 index 0000000..91a05d3 --- /dev/null +++ b/test_project/zappa_settings.yaml @@ -0,0 +1,7 @@ +test: + app_function: test.app + aws_region: us-east-1 + profile_name: default + project_name: zappa-deploy-test + runtime: python3.7 + s3_bucket: zappa-deploy-action-test-deploy \ No newline at end of file