From 78299bf969e7322364b89f7682ae63ef39b75363 Mon Sep 17 00:00:00 2001 From: Chisel Date: Mon, 9 Oct 2023 19:48:59 +0100 Subject: [PATCH] chore: update deploy workflow to be terraform only --- .../workflows/terraform-serverless-deploy.yml | 131 +----------------- 1 file changed, 5 insertions(+), 126 deletions(-) diff --git a/.github/workflows/terraform-serverless-deploy.yml b/.github/workflows/terraform-serverless-deploy.yml index 1851e876..9852595d 100644 --- a/.github/workflows/terraform-serverless-deploy.yml +++ b/.github/workflows/terraform-serverless-deploy.yml @@ -89,6 +89,11 @@ jobs: # a PR with a normal release version number poetry version prerelease + - name: Run Tests + shell: bash + run: | + make test + - name: Run terraform actions id: run-terraform-actions # yamllint disable-line rule:line-length @@ -111,132 +116,6 @@ jobs: auto-apply: ${{ github.event_name == 'pull_request' || github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} # yamllint enable rule:line-length - linting: - name: Deploy Lambda - runs-on: ubuntu-latest - - strategy: - matrix: - include: - - aws-account-name: chizography - aws-account-id: 436158765452 - aws-deployment-role: botc/deploy_json2pdf - - steps: - - uses: actions/checkout@v4 - - # do this early so it can fail fast - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - # yamllint disable rule:line-length - aws-access-key-id: ${{ secrets.CHIZOGRAPHY_GITHUB_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.CHIZOGRAPHY_GITHUB_AWS_SECRET_ACCESS_KEY }} - aws-region: eu-west-2 - role-to-assume: arn:aws:iam::${{ matrix.aws-account-id }}:role/${{ matrix.aws-deployment-role }} - role-skip-session-tagging: true - role-duration-seconds: 1800 # 30 minute session - mask-aws-account-id: false - # yamllint enable rule:line-length - - - name: Show AWS Credentials - shell: bash - run: | - env |sort |grep AWS - aws sts get-caller-identity - - - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: Set Environment Env - # if we're a PR then we user 'dev', otherwise we use 'prod' - # yamllint disable rule:line-length - run: | - # debug pesky sls - echo "SLS_DEBUG=*" >> "$GITHUB_ENV" - - # pull request - if [ -n "${{ github.event.pull_request.head.sha }}" ]; then - echo "DEPLOY_ENV=dev" >> "$GITHUB_ENV" - - # push to default branch - elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then - echo "DEPLOY_ENV=prod" >> "$GITHUB_ENV" - - # it's a tag event - elif [ "${{ github.event_name }}" == "push" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then - echo "DEPLOY_ENV=prod" >> "$GITHUB_ENV" - - # no idea what's going on - else - # ::error - echo "::error::Unknown event type: ${{ github.event_name }} ${{ github.ref }}" - exit 66 - fi - # yamllint enable rule:line-length - - - name: SLS Prep - shell: bash - run: | - npm --version - npm install -g serverless@3 - serverless plugin install -n serverless-docker - - - name: Debug Matrix - shell: bash - run: | - echo "::notice::aws-account-name: ${{matrix.aws-account-name}}" - echo "::notice::aws-account-id: ${{matrix.aws-account-id}}" - echo "::notice::aws-deployment-role: ${{matrix.aws-deployment-role}}" - echo "::notice::DEPLOY_ENV: ${{env.DEPLOY_ENV}}" - - # install python and poetry so we can run the tests - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Setup Poetry - uses: abatilo/actions-poetry@v2 - with: - poetry-version: 1.4.2 - - - name: Prerelease Version - shell: bash - if: github.event_name == 'pull_request' - run: | - # for convenience we bump the version number (prerelease) if we're a - # PR; we don't care about keeping this, we just _never_ want to have - # a PR with a normal release version number - poetry version prerelease - - - name: Run Tests - shell: bash - run: | - make test - - - name: SLS List Deploy - shell: bash - run: | - sls deploy list - - - name: Install AWS RIE - shell: bash - # yamllint disable rule:line-length - run: | - mkdir -p ~/.aws-lambda-rie \ - && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie \ - && chmod +x ~/.aws-lambda-rie/aws-lambda-rie - # yamllint enable rule:line-length - - - name: SLS Deploy (by env) - shell: bash - # yamllint disable-line rule:line-length - if: github.event_name == 'pull_request' || github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - run: | - sls deploy --stage ${{ env.DEPLOY_ENV }} - - name: Notify Discord uses: th0th/notify-discord@v0.4.1 if: ${{ always() }}