|
| 1 | +name: Build and deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + secrets: |
| 6 | + role_arn: |
| 7 | + required: true |
| 8 | + artifact_bucket: |
| 9 | + required: true |
| 10 | + # ecr_repository_test: |
| 11 | + # required: true |
| 12 | + # ecr_repository_traffic_test: |
| 13 | + # required: true |
| 14 | + # container_sign_kms_key: |
| 15 | + # required: true |
| 16 | + signing_profile: |
| 17 | + required: true |
| 18 | + # environment: |
| 19 | + # required: true |
| 20 | + # dynatrace_paas_token: |
| 21 | + # required: true |
| 22 | + inputs: |
| 23 | + region: |
| 24 | + required: false |
| 25 | + type: string |
| 26 | + default: eu-west-2 |
| 27 | + |
| 28 | +permissions: |
| 29 | + id-token: write |
| 30 | + contents: read |
| 31 | + |
| 32 | +jobs: |
| 33 | + # test-images-build-and-push: |
| 34 | + # name: Build and push test images |
| 35 | + # runs-on: ubuntu-latest |
| 36 | + # env: |
| 37 | + # AWS_REGION: eu-west-2 |
| 38 | + # ENVIRONMENT: ${{ secrets.environment }} |
| 39 | + # is this needed? |
| 40 | + # could these run in paralell? |
| 41 | + # steps: |
| 42 | + # why ? |
| 43 | + # - name: Login to Dynatrace Container Registry |
| 44 | + # uses: docker/login-action@v4 |
| 45 | + # with: |
| 46 | + # registry: khw46367.live.dynatrace.com |
| 47 | + # username: khw46367 |
| 48 | + # password: ${{ secrets.dynatrace_paas_token }} |
| 49 | + |
| 50 | + # # this checkouts, sets up AWS creds and logs into docker registry |
| 51 | + # - name: Test image build and push |
| 52 | + # uses: uses: govuk-one-login/devplatform-upload-action-ecr@v1.5.0 |
| 53 | + # with: |
| 54 | + # role-to-assume-arn: ${{ secrets.role_arn }} |
| 55 | + # build-and-push-image-only: true |
| 56 | + # working-directory: test |
| 57 | + # artifact-bucket-name: "" # ? shouldnt that be optional? |
| 58 | + # ecr-repo-name: ${{ secrets.ecr_repository_test }} |
| 59 | + # push-latest-tag: true |
| 60 | + # container-sign-kms-key-arn: ${{ secrets.container_sign_kms_key }} # ? |
| 61 | + |
| 62 | + # # this checkouts, sets up AWS creds and logs into docker registry |
| 63 | + # - name: Traffic test image build and push |
| 64 | + # uses: uses: govuk-one-login/devplatform-upload-action-ecr@v1.5.0 |
| 65 | + # with: |
| 66 | + # role-to-assume-arn: ${{ secrets.role_arn }} |
| 67 | + # build-and-push-image-only: true |
| 68 | + # working-directory: test |
| 69 | + # artifact-bucket-name: "" # ? shouldnt that be optional? |
| 70 | + # ecr-repo-name: ${{ secrets.ecr_repository_traffic_test }} |
| 71 | + # dockerfile: Dockerfile-traffictest # think about name |
| 72 | + # push-latest-tag: true # ? |
| 73 | + # container-sign-kms-key-arn: ${{ secrets.container_sign_kms_key }} # ? |
| 74 | + # UNCOMMENT LAST in case cosign blocks ^ |
| 75 | + # hopefully can run pipeline without test images - might have to change terraform for build? |
| 76 | + # hasn't blocked front though - whats the difference? |
| 77 | + |
| 78 | + deploy: |
| 79 | + name: Deploy stack |
| 80 | + runs-on: ubuntu-latest |
| 81 | + # needs: test-images-build-and-push |
| 82 | + steps: |
| 83 | + - name: Checkout |
| 84 | + uses: actions/checkout@v6 |
| 85 | + |
| 86 | + - name: Assume temporary AWS role |
| 87 | + uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0 |
| 88 | + with: |
| 89 | + role-to-assume: ${{ secrets.role_arn }} |
| 90 | + aws-region: ${{ inputs.region }} |
| 91 | + |
| 92 | + - name: SAM validate |
| 93 | + run: sam validate --region ${{ inputs.region }} -t deploy/template.yaml --lint |
| 94 | + |
| 95 | + - name: SAM build |
| 96 | + run: | |
| 97 | + mkdir out |
| 98 | + sam build -t deploy/template.yaml --region ${{ inputs.region }} -b out/ |
| 99 | +
|
| 100 | + - name: SAM Deploy |
| 101 | + # concurrency and cancel in progress false |
| 102 | + uses: govuk-one-login/devplatform-upload-action@v3.13.0 |
| 103 | + with: |
| 104 | + aws-role-arn: ${{ secrets.role_arn}} |
| 105 | + artifact-bucket-name: ${{ secrets.artifact_bucket }} |
| 106 | + signing-profile-name: ${{ secrets.signing_profile }} |
| 107 | + working-directory: ./out |
0 commit comments