-
Notifications
You must be signed in to change notification settings - Fork 1
LIME-2030: Setting up GHAs #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| name: Build and deploy | ||
|
|
||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| role_arn: | ||
| required: true | ||
| artifact_bucket: | ||
| required: true | ||
| ecr_repository_test: | ||
| required: true | ||
| ecr_repository_traffic_test: | ||
| required: true | ||
| container_sign_kms_key: | ||
| required: true | ||
| signing_profile: | ||
| required: true | ||
| inputs: | ||
| environment: | ||
| type: string | ||
| required: true | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: secure-deploy-${{ inputs.environment }} | ||
|
|
||
| jobs: | ||
| test-images-build-and-push: | ||
| name: Build and push test images | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Test image build and push | ||
| uses: govuk-one-login/devplatform-upload-action-ecr@v1.5.0 | ||
| with: | ||
| role-to-assume-arn: ${{ secrets.role_arn }} | ||
| build-and-push-image-only: true | ||
| working-directory: test/acceptance-tests | ||
| artifact-bucket-name: '' | ||
| ecr-repo-name: ${{ secrets.ecr_repository_test }} | ||
| dockerfile: test.Dockerfile | ||
| push-latest-tag: true | ||
| container-sign-kms-key-arn: ${{ secrets.container_sign_kms_key }} | ||
|
|
||
| - name: Traffic test image build and push | ||
| uses: govuk-one-login/devplatform-upload-action-ecr@v1.5.0 | ||
| with: | ||
| role-to-assume-arn: ${{ secrets.role_arn }} | ||
| build-and-push-image-only: true | ||
| working-directory: test/acceptance-tests | ||
| artifact-bucket-name: '' | ||
| ecr-repo-name: ${{ secrets.ecr_repository_traffic_test }} | ||
| dockerfile: traffic-test.Dockerfile | ||
| push-latest-tag: true | ||
| container-sign-kms-key-arn: ${{ secrets.container_sign_kms_key }} | ||
|
|
||
| deploy: | ||
| name: Deploy stack | ||
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.environment }} | ||
| needs: test-images-build-and-push | ||
| steps: | ||
| - name: SAM build | ||
| uses: govuk-one-login/github-actions/sam/build-application@4c76410195b5fcb1804fc7c183ed20704252830f | ||
| with: | ||
| template: deploy/template.yaml | ||
| aws-role-arn: ${{ secrets.role_arn }} | ||
| pull-repository: true | ||
|
|
||
| - name: SAM package and upload to S3 | ||
| uses: govuk-one-login/devplatform-upload-action@v3.13.0 | ||
| with: | ||
| aws-role-arn: ${{ secrets.role_arn}} | ||
| artifact-bucket-name: ${{ secrets.artifact_bucket }} | ||
| signing-profile-name: ${{ secrets.signing_profile }} | ||
| working-directory: .aws-sam/build |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: Clean up stacks and log groups | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| # Every weekday at 9am | ||
| - cron: '0 9 * * 1-5' | ||
|
|
||
| permissions: | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: cleanup-dev | ||
|
|
||
| jobs: | ||
| delete-stacks: | ||
| name: Delete stale stacks | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Assume AWS Role | ||
| uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0 | ||
| with: | ||
| role-to-assume: ${{ secrets.DEV_GHA_PREVIEW_ROLE_ARN }} | ||
| aws-region: eu-west-2 | ||
|
|
||
| - name: Get stale preview stacks | ||
| uses: govuk-one-login/github-actions/sam/get-stale-stacks@4c76410195b5fcb1804fc7c183ed20704252830f | ||
| with: | ||
| threshold-days: 14 | ||
| stack-name-filter: preview | ||
| stack-tag-filters: | | ||
| cri:deployment-source=github-actions | ||
| cri:stack-type=preview | ||
| description: preview | ||
| env-var-name: PREVIEW_STACKS | ||
|
|
||
| - name: Get stale manually deployed stacks | ||
| uses: govuk-one-login/github-actions/sam/get-stale-stacks@4c76410195b5fcb1804fc7c183ed20704252830f | ||
| with: | ||
| threshold-days: 90 | ||
| stack-tag-filters: | | ||
| cri:component=ipv-cri-ob-api | ||
| cri:stack-type=dev | ||
| cri:application=Lime | ||
| cri:deployment-source=manual | ||
| description: manually deployed | ||
| env-var-name: MANUALLY_DEPLOYED_STACKS | ||
|
|
||
| - name: Delete stale preview stacks | ||
| if: ${{ env.PREVIEW_STACKS != null }} | ||
| uses: govuk-one-login/github-actions/sam/delete-stacks@2518d831abb4ec03fa3125619507f932966f2833 | ||
| with: | ||
| stack-names: ${{ env.PREVIEW_STACKS }} | ||
| verbose: true | ||
|
|
||
| - name: Delete stale manually deployed stacks | ||
| if: ${{ env.MANUALLY_DEPLOYED_STACKS != null }} | ||
| uses: govuk-one-login/github-actions/sam/delete-stacks@2518d831abb4ec03fa3125619507f932966f2833 | ||
| with: | ||
| stack-names: ${{ env.MANUALLY_DEPLOYED_STACKS }} | ||
| verbose: true | ||
|
|
||
| delete-log-groups: | ||
| name: Delete stale log groups | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: govuk-one-login/github-actions/sam/delete-stale-log-groups@4c76410195b5fcb1804fc7c183ed20704252830f | ||
| with: | ||
| aws-role-arn: ${{ secrets.DEV_GHA_PREVIEW_ROLE_ARN }} | ||
| cutoff-days: 30 | ||
| limit: 300 | ||
| safe-patterns: '/preview-|^API-Gateway-Execution-Logs_' | ||
| destructive: true | ||
| verbose: true |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: Deploy branch to dev | ||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| deploy-dev: | ||
| name: Deploy to dev | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| concurrency: | ||
| group: deploy-to-dev | ||
| uses: ./.github/workflows/_secure-pipeline-deploy.yml | ||
| secrets: | ||
| role_arn: ${{ secrets.DEV_GHA_ROLE_ARN }} | ||
| artifact_bucket: ${{ secrets.DEV_ARTIFACT_BUCKET }} | ||
| ecr_repository_test: ${{ secrets.DEV_ECR_TEST }} | ||
| ecr_repository_traffic_test: ${{ secrets.DEV_ECR_TRAFFIC_TEST }} | ||
| container_sign_kms_key: $ {{ secrets.DEV_CONTAINER_SIGN_KMS_KEY }} | ||
| signing_profile: ${{ secrets.DEV_SIGNING_PROFILE_NAME }} | ||
| with: | ||
| environment: development | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| name: Deploy preview | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| workflow_call: | ||
| secrets: | ||
| role_arn: | ||
| required: true | ||
| bucket_name: | ||
| required: true | ||
| outputs: | ||
| stack-name: | ||
| value: ${{ jobs.deploy-preview.outputs.stack-name }} | ||
| aws-region: | ||
| value: ${{ jobs.deploy-preview.outputs.aws-region}} | ||
|
|
||
| permissions: {} | ||
| concurrency: | ||
| group: deploy-preview-${{ github.event.pull_request.number || github.ref_name || github.run_id }} | ||
|
|
||
| jobs: | ||
| build-preview: | ||
| name: Build app | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| sha-short: ${{ steps.get-sha.outputs.sha-short }} | ||
| steps: | ||
| - name: Get short SHA | ||
| id: get-sha | ||
| run: echo "sha-short=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Build app | ||
| uses: govuk-one-login/github-actions/sam/build-application@4c76410195b5fcb1804fc7c183ed20704252830f | ||
| with: | ||
| template: deploy/template.yaml | ||
| cache-name: ipv-cri-ob-api-${{ steps.get-sha.outputs.sha-short }} | ||
| aws-role-arn: ${{ secrets.role_arn || secrets.DEV_GHA_PREVIEW_ROLE_ARN }} | ||
| pull-repository: true | ||
|
|
||
| deploy-preview: | ||
| name: Deploy stack | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| timeout-minutes: 15 | ||
| needs: build-preview | ||
| outputs: | ||
| aws-region: ${{ steps.deploy.outputs.aws-region }} | ||
| stack-name: ${{ steps.deploy.outputs.stack-name }} | ||
| steps: | ||
| - name: Deploy stack | ||
| uses: govuk-one-login/github-actions/sam/deploy-stack@4c76410195b5fcb1804fc7c183ed20704252830f | ||
| id: deploy | ||
| with: | ||
| aws-role-arn: ${{ secrets.role_arn || secrets.DEV_GHA_PREVIEW_ROLE_ARN }} | ||
| s3-prefix: preview | ||
| sam-deployment-bucket: ${{ secrets.bucket_name || secrets.DEV_PREVIEW_ARTIFACT_BUCKET }} | ||
| stack-name: preview-${{ needs.build-preview.outputs.sha-short}} | ||
| cache-name: ipv-cri-ob-api-${{ needs.build-preview.outputs.sha-short}} | ||
| delete-failed-stack: true | ||
|
|
||
| tags: | | ||
| cri:component=ipv-cri-ob-api | ||
| cri:stack-type=preview | ||
| cri:application=Lime | ||
| cri:deployment-source=github-actions | ||
| parameters: | | ||
| DeploymentType=not-pipeline | ||
| Environment=dev | ||
| ParameterPrefix="ipv-cri-ob-api" |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.