diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml index f25dd22..7ad5352 100644 --- a/.github/actions/deploy/action.yml +++ b/.github/actions/deploy/action.yml @@ -7,6 +7,9 @@ inputs: description: "The name of the Terraform workspace to use" required: true default: "default" + sha: + description: "The commit SHA to deploy" + required: true aws_access_key_id: description: "AWS access key ID" required: true @@ -39,15 +42,20 @@ runs: echo "sentry_dsn = \"${{ inputs.sentry_dsn }}\"" > ${TF_VAR_FILE} echo "telegram_token = \"${{ inputs.telegram_token }}\"" >> ${TF_VAR_FILE} shell: bash + - name: Download deploy artifact + uses: actions/download-artifact@v2 + with: + name: deployment-${{ inputs.sha }} + path: deployment.zip + - name: Unzip deploy artifact + run: unzip deployment.zip + shell: bash - name: Install CI dependencies run: make install-ci shell: bash - name: Terraform init run: cd tf; terraform init shell: bash - - name: Build Lambda Layer - run: make build-layer - shell: bash - name: Terraform plan run: make plan WORKSPACE=${{ inputs.workspace }} shell: bash diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 712c7cd..26aa9a6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -22,7 +22,7 @@ jobs: run: | make test - build-layer: + build-deployment: runs-on: ubuntu-latest steps: - name: Checkout repo @@ -34,20 +34,22 @@ jobs: - name: Install dependencies run: | make install-ci - make install-test - name: Build Lambda Layer run: make build-layer - - name: Upload Lambda Layer + - name: Archive .deployment folder + run: zip -r deployment.zip .deployment + - name: Upload deployment artifact uses: actions/upload-artifact@v2 with: - name: layer - path: layer.zip + name: deployment-${{ github.sha }} + path: deployment.zip deploy-dev: if: ${{ github.ref == 'refs/heads/main' }} runs-on: ubuntu-latest needs: - unit-tests + - build-deployment steps: - name: Checkout repo uses: actions/checkout@v2 @@ -55,6 +57,7 @@ jobs: uses: ./.github/actions/deploy with: workspace: default + sha: ${{ github.sha }} aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_region: us-east-1 @@ -94,6 +97,7 @@ jobs: uses: ./.github/actions/deploy with: workspace: prod + sha: ${{ github.sha }} aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws_region: us-east-1