Merge pull request #9 from jmeisele/jmeisele-patch-1 #38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Continuous Deployment | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| create-lambda-layer-zip: | |
| name: Create lambda layer zip | |
| runs-on: ubuntu-20.04 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python 3.8.1 | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: 3.8.1 | |
| - name: Install aws-xray-sdk | |
| run: | | |
| pip3 install aws-xray-sdk -t ./python | |
| - name: Zip aws-xray-sdk | |
| run: | | |
| zip -r layer.zip ./python | |
| - name: Upload layer.zip artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: layer | |
| path: ./layer.zip | |
| deploy-infra: | |
| needs: create-lambda-layer-zip | |
| name: Deploy Infrastructure w/ Terraform | |
| runs-on: ubuntu-20.04 | |
| permissions: | |
| contents: read | |
| id-token: write | |
| packages: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Download layer.zip | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: layer | |
| - name: Generate .auto.tfvars | |
| run: | | |
| echo "access_key=\"${{ secrets.AWS_ACCESS_KEY_ID }}\"" >> ./.auto.tfvars | |
| echo "secret_key=\"${{ secrets.AWS_SECRET_ACCESS_KEY }}\"" >> ./.auto.tfvars | |
| echo "---------------------------------------------------------" | |
| cat ./.auto.tfvars | |
| echo "---------------------------------------------------------" | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v2 | |
| with: | |
| cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
| - name: Terrform format | |
| id: fmt | |
| run: terraform fmt -check | |
| - name: Terraform Init | |
| id: init | |
| env: | |
| TF_TOKEN: ${{ secrets.TF_API_TOKEN }} | |
| run: terraform init | |
| - name: Terraform validate | |
| id: validate | |
| run: terraform validate -no-color | |
| - name: Terraform Plan | |
| id: plan | |
| if: github.event_name == 'pull_request' | |
| run: terraform plan -no-color -input=false | |
| continue-on-error: true | |
| - name: Terraform Plan Status | |
| if: steps.plan.outcome == 'failure' | |
| run: exit 1 | |
| - name: Terraform Apply | |
| run: terraform apply -auto-approve -input=false |