Attempt to integrate e2e with deploying the backend #16
Workflow file for this run
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: Deploy Backend | ||
|
Check failure on line 1 in .github/workflows/deploy-backend.yml
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| apigee_environment: | ||
| required: true | ||
| type: string | ||
| create_mns_subscription: | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| environment: | ||
| required: true | ||
| type: string | ||
| sub_environment: | ||
| required: true | ||
| type: string | ||
| workflow_dispatch: | ||
| inputs: | ||
| apigee_environment: | ||
| type: choice | ||
| description: Select the Apigee proxy environment | ||
| options: | ||
| - internal-dev | ||
| - internal-dev-sandbox | ||
| - sandbox | ||
| - int | ||
| - ref | ||
| - prod | ||
| create_mns_subscription: | ||
| description: Create an MNS Subscription. Only available in dev | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| environment: | ||
| type: choice | ||
| description: Select the backend environment | ||
| options: | ||
| - dev | ||
| - preprod | ||
| - prod | ||
| sub_environment: | ||
| type: string | ||
| description: Set the sub environment name e.g. pr-xxx, or green/blue in higher environments | ||
| env: # Sonarcloud - do not allow direct usage of untrusted data | ||
| APIGEE_ENVIRONMENT: ${{ inputs.apigee_environment }} | ||
| BACKEND_REQUIRED: ${{ !(inputs.apigee_environment == 'internal-dev-sandbox' || inputs.apigee_environment == 'sandbox') }} | ||
| ENVIRONMENT: ${{ inputs.environment }} | ||
| SUB_ENVIRONMENT: ${{ inputs.sub_environment }} | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| jobs: | ||
| terraform-plan: | ||
| if: ${{ env.BACKEND_REQUIRED == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: ${{ inputs.environment }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 | ||
| - name: Connect to AWS | ||
| uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 | ||
| with: | ||
| aws-region: eu-west-2 | ||
| role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops | ||
| role-session-name: github-actions | ||
| - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd | ||
| with: | ||
| terraform_version: "1.12.2" | ||
| - name: Terraform Init | ||
| working-directory: terraform | ||
| run: make init | ||
| - name: Terraform Plan | ||
| working-directory: terraform | ||
| run: make plan-ci | ||
| - name: Save Terraform Plan | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 | ||
| with: | ||
| name: tfplan | ||
| path: terraform/tfplan | ||
| terraform-apply: | ||
| if: ${{ env.BACKEND_REQUIRED == 'true' }} | ||
| needs: terraform-plan | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: ${{ inputs.environment }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 | ||
| - uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a | ||
| with: | ||
| aws-region: eu-west-2 | ||
| role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops | ||
| role-session-name: github-actions | ||
| - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd | ||
| with: | ||
| terraform_version: "1.12.2" | ||
| - name: Retrieve Terraform Plan | ||
| uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 | ||
| with: | ||
| name: tfplan | ||
| path: terraform | ||
| - name: Terraform Init | ||
| working-directory: terraform | ||
| run: make init | ||
| - name: Terraform Apply | ||
| working-directory: terraform | ||
| run: | | ||
| make apply-ci | ||
| echo "ID_SYNC_QUEUE_ARN=$(make -s output name=id_sync_queue_arn)" >> $GITHUB_ENV | ||
| - name: Install poetry | ||
| if: ${{ inputs.environment == 'dev' && inputs.create_mns_subscription }} | ||
| run: pip install poetry==2.1.4 | ||
| - uses: actions/setup-python@v6 | ||
| if: ${{ inputs.environment == 'dev' && inputs.create_mns_subscription }} | ||
| with: | ||
| python-version: 3.11 | ||
| cache: "poetry" | ||
| cache-dependency-path: | | ||
| lambdas/mns_subscription/poetry.lock | ||
| lambdas/shared/poetry.lock | ||
| - name: Create MNS Subscription | ||
| if: ${{ inputs.environment == 'dev' && inputs.create_mns_subscription }} | ||
| working-directory: "./lambdas/mns_subscription" | ||
| env: | ||
| SQS_ARN: ${{ env.ID_SYNC_QUEUE_ARN }} | ||
| run: | | ||
| poetry install --no-root | ||
| echo "Subscribing SQS to MNS for notifications..." | ||
| make subscribe | ||
| run-e2e-tests: | ||
| uses: ./.github/workflows/run-e2e-tests.yml | ||
| with: | ||
| apigee_environment: ${{ inputs.apigee_environment }} | ||
| environment: ${{ inputs.environment }} | ||
| sub_environment: ${{ inputs.sub_environment }} | ||