|
| 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 | + inputs: |
| 19 | + region: |
| 20 | + required: false |
| 21 | + type: string |
| 22 | + default: eu-west-2 |
| 23 | + environment: |
| 24 | + type: string |
| 25 | + required: true |
| 26 | + |
| 27 | +permissions: |
| 28 | + id-token: write |
| 29 | + contents: read |
| 30 | + |
| 31 | +concurrency: |
| 32 | + group: secure-deploy-${{ inputs.environment }} |
| 33 | + |
| 34 | +jobs: |
| 35 | + test-images-build-and-push: |
| 36 | + name: Build and push test images |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - name: Test image build and push |
| 40 | + uses: govuk-one-login/devplatform-upload-action-ecr@v1.5.0 |
| 41 | + with: |
| 42 | + role-to-assume-arn: ${{ secrets.role_arn }} |
| 43 | + build-and-push-image-only: true |
| 44 | + working-directory: test/acceptance-tests |
| 45 | + artifact-bucket-name: '' |
| 46 | + ecr-repo-name: ${{ secrets.ecr_repository_test }} |
| 47 | + dockerfile: test.Dockerfile |
| 48 | + push-latest-tag: true |
| 49 | + container-sign-kms-key-arn: ${{ secrets.container_sign_kms_key }} |
| 50 | + |
| 51 | + - name: Traffic test image build and push |
| 52 | + 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/acceptance-tests |
| 57 | + artifact-bucket-name: '' |
| 58 | + ecr-repo-name: ${{ secrets.ecr_repository_traffic_test }} |
| 59 | + dockerfile: traffic-test.Dockerfile |
| 60 | + push-latest-tag: true |
| 61 | + container-sign-kms-key-arn: ${{ secrets.container_sign_kms_key }} |
| 62 | + |
| 63 | + deploy: |
| 64 | + name: Deploy stack |
| 65 | + runs-on: ubuntu-latest |
| 66 | + environment: ${{ inputs.environment }} |
| 67 | + needs: test-images-build-and-push |
| 68 | + steps: |
| 69 | + # - name: Checkout |
| 70 | + # uses: actions/checkout@v6 |
| 71 | + |
| 72 | + # - name: Assume temporary AWS role |
| 73 | + # uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0 |
| 74 | + # with: |
| 75 | + # role-to-assume: ${{ secrets.role_arn }} |
| 76 | + # aws-region: ${{ inputs.region }} |
| 77 | + |
| 78 | + # - name: SAM validate |
| 79 | + # run: sam validate --region ${{ inputs.region }} -t deploy/template.yaml --lint |
| 80 | + |
| 81 | + # - name: SAM build |
| 82 | + # run: | |
| 83 | + # mkdir out |
| 84 | + # sam build -t deploy/template.yaml --region ${{ inputs.region }} -b out/ |
| 85 | + |
| 86 | + - name: Build app |
| 87 | + uses: govuk-one-login/github-actions/sam/build-application@350c58b28e56f0fd67c4a8d8c8cd4fdc6355bdf3 # my branch - change once merged |
| 88 | + with: |
| 89 | + template: deploy/template.yaml |
| 90 | + aws-role-arn: ${{ secrets.role_arn }} |
| 91 | + pull-repository: true |
| 92 | + |
| 93 | + - name: SAM package and upload to S3 |
| 94 | + uses: govuk-one-login/devplatform-upload-action@v3.13.0 |
| 95 | + with: |
| 96 | + aws-role-arn: ${{ secrets.role_arn}} |
| 97 | + artifact-bucket-name: ${{ secrets.artifact_bucket }} |
| 98 | + signing-profile-name: ${{ secrets.signing_profile }} |
0 commit comments