|
| 1 | +name: Deploy to INT and run E2e test |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + environment: |
| 6 | + required: true |
| 7 | + type: string |
| 8 | + |
| 9 | +jobs: |
| 10 | + terraform-plan: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + id-token: write |
| 14 | + contents: read |
| 15 | + steps: |
| 16 | + - name: Debug OIDC |
| 17 | + uses: aws-actions/configure-aws-credentials@v4 |
| 18 | + with: |
| 19 | + aws-region: eu-west-2 |
| 20 | + role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops |
| 21 | + role-session-name: github-actions |
| 22 | + |
| 23 | + - name: Whoami |
| 24 | + run: aws sts get-caller-identity |
| 25 | + |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 1 |
| 30 | + |
| 31 | + - uses: hashicorp/setup-terraform@v3 |
| 32 | + with: |
| 33 | + terraform_version: "1.12.2" |
| 34 | + |
| 35 | + - name: Terraform Init |
| 36 | + working-directory: ${{ vars.TERRAFORM_DIR_PATH }} |
| 37 | + run: | |
| 38 | + export ENVIRONMENT=${{ inputs.environment }} |
| 39 | + make init |
| 40 | +
|
| 41 | + - name: Terraform Plan |
| 42 | + working-directory: ${{ vars.TERRAFORM_DIR_PATH }} |
| 43 | + run: | |
| 44 | + make plan environment=${{ inputs.environment }} aws_account_name=int |
| 45 | +
|
| 46 | + terraform-apply: |
| 47 | + needs: terraform-plan |
| 48 | + runs-on: ubuntu-latest |
| 49 | + permissions: |
| 50 | + id-token: write |
| 51 | + contents: read |
| 52 | + environment: |
| 53 | + name: int |
| 54 | + steps: |
| 55 | + - name: Checkout |
| 56 | + uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - uses: aws-actions/configure-aws-credentials@v4 |
| 59 | + with: |
| 60 | + aws-region: eu-west-2 |
| 61 | + role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops |
| 62 | + role-session-name: github-actions |
| 63 | + |
| 64 | + - uses: hashicorp/setup-terraform@v3 |
| 65 | + with: |
| 66 | + terraform_version: "1.12.2" |
| 67 | + |
| 68 | + - name: Terraform Init |
| 69 | + working-directory: ${{ vars.TERRAFORM_DIR_PATH }} |
| 70 | + run: | |
| 71 | + export ENVIRONMENT=${{ inputs.environment }} |
| 72 | + make init |
| 73 | +
|
| 74 | + - name: Terraform Apply |
| 75 | + working-directory: ${{ vars.TERRAFORM_DIR_PATH }} |
| 76 | + run: | |
| 77 | + make apply environment=${{ inputs.environment }} aws_account_name=int |
| 78 | +
|
| 79 | + e2e-tests: |
| 80 | + needs: terraform-apply |
| 81 | + if: ${{ vars.RUN_E2E == 'true' || inputs.environment == vars.ACTIVE_ENVIRONMENT }} |
| 82 | + runs-on: ubuntu-latest |
| 83 | + permissions: |
| 84 | + id-token: write |
| 85 | + contents: read |
| 86 | + steps: |
| 87 | + - name: Checkout |
| 88 | + uses: actions/checkout@v4 |
| 89 | + |
| 90 | + - uses: aws-actions/configure-aws-credentials@v4 |
| 91 | + with: |
| 92 | + aws-region: eu-west-2 |
| 93 | + role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops |
| 94 | + role-session-name: github-actions |
| 95 | + |
| 96 | + - name: Set up Python |
| 97 | + uses: actions/setup-python@v5 |
| 98 | + with: |
| 99 | + python-version: "3.11" |
| 100 | + |
| 101 | + - name: Install Poetry |
| 102 | + run: | |
| 103 | + curl -sSL https://install.python-poetry.org | python3 - |
| 104 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 105 | +
|
| 106 | + - name: Set Poetry to use Python 3.11 |
| 107 | + working-directory: ${{ vars.E2E_DIR_PATH }} |
| 108 | + run: | |
| 109 | + poetry env use $(which python3.11) |
| 110 | +
|
| 111 | + - name: Install dependencies with Poetry |
| 112 | + working-directory: ${{ vars.E2E_DIR_PATH }} |
| 113 | + run: | |
| 114 | + poetry install --no-root |
| 115 | +
|
| 116 | + - name: Run e2e tests |
| 117 | + working-directory: ${{ vars.E2E_DIR_PATH }} |
| 118 | + run: | |
| 119 | + apigee_token=$(aws ssm get-parameter \ |
| 120 | + --name "/imms/apigee/non-prod/token" \ |
| 121 | + --with-decryption \ |
| 122 | + --query "Parameter.Value" \ |
| 123 | + --output text) |
| 124 | +
|
| 125 | + status_api_key=$(aws ssm get-parameter \ |
| 126 | + --name "/imms/apigee/non-prod/status-api-key" \ |
| 127 | + --with-decryption \ |
| 128 | + --query "Parameter.Value" \ |
| 129 | + --output text) |
| 130 | +
|
| 131 | + export APIGEE_ACCESS_TOKEN=$apigee_token |
| 132 | + |
| 133 | + export APIGEE_ENVIRONMENT=int |
| 134 | + export STATUS_API_KEY=$status_api_key |
| 135 | + export PROXY_NAME=immunisation-fhir-api-internal-dev |
| 136 | + export SERVICE_BASE_PATH=immunisation-fhir-api/FHIR/R4 |
| 137 | + export SSO_LOGIN_URL=https://login.apigee.com |
| 138 | +
|
| 139 | + make run-immunization |
0 commit comments