diff --git a/.github/workflows/blackformat.yml b/.github/workflows/blackformat.yml index a2169b9..af72468 100644 --- a/.github/workflows/blackformat.yml +++ b/.github/workflows/blackformat.yml @@ -2,6 +2,7 @@ name: Black Code Formatter Check on: push: + branches: [ master ] pull_request: jobs: diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 0000000..128bf3f --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,71 @@ +name: deployment + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + #when there is a push to the master + push: + branches: [ master ] + pull_request: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + #does this mean that the files in my github repo are accessible by this YAML file? + - uses: actions/checkout@v2 + + #installs a version of python, but I need this if deploying to a severless Python Lambda? + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.6' + + #credentials to connect to AWS + # - name: Configure AWS credentials from Production account + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # aws-region: us-east-1 + + # Runs a set of commands using the runners shell; THIS DOESN'T WORK + - name: Run a multi-line script + env: + DEBUG: 'False' + ENV: prod + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }} + run: | + #install PIP + python -m pip install --upgrade pip + cd src/ + #install all dependencies as defined by requirements.txt in the current directory + pip3 install -r ../requirements.txt -t . + pip3 install python-dotenv==0.14.0 + python manage.py collectstatic --noinput + zip -r ../pycon.zip . + + #ensuring current working directory is accessible by the function--this might not be doing anything + export PATH=$PATH:$(pwd) + + #${{ secrets.AWS_FUNCTION_NAME }} + #Deploy main.py to AWS + - name: AWS Lambda Deploy + uses: appleboy/lambda-action@v0.0.4 + with: + aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws_region: us-east-1 + #name of my AWS Lambda Function + function_name: pycon-demo-test + #contains all the files in my github repository + zip_file: pycon.zip \ No newline at end of file