Merge pull request #583 from ministryofjustice/dependabot/github_acti… #187
This file contains 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: modernisation-platform | |
on: | |
push: | |
branches: | |
- main | |
- feature/* | |
paths: | |
- 'modernisation-platform/**' | |
- '.github/workflows/modernisation-platform.yml' | |
pull_request: | |
branches: | |
- main | |
types: [opened, edited, reopened, synchronize] | |
paths: | |
- 'modernisation-platform/**' | |
- '.github/workflows/modernisation-platform.yml' | |
workflow_dispatch: | |
env: | |
AWS_REGION: "eu-west-2" | |
ENVIRONMENT_MANAGEMENT: ${{ secrets.MODERNISATION_PLATFORM_ENVIRONMENTS }} | |
TF_IN_AUTOMATION: true | |
permissions: {} | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
plan-modernisation-platform: | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
name: Plan - modernisation-platform pipelines | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
- name: Set Account Number | |
run: echo "ACCOUNT_NUMBER=$(jq -r -e '.modernisation_platform_account_id' <<< $ENVIRONMENT_MANAGEMENT)" >> $GITHUB_ENV | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0 | |
with: | |
role-to-assume: "arn:aws:iam::${{ env.ACCOUNT_NUMBER }}:role/github-actions" | |
role-session-name: githubactionsrolesession | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Load and Configure Terraform | |
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 | |
with: | |
terraform_version: ~> 1.0 | |
terraform_wrapper: false | |
- name: Terraform plan - modernisation-platform pipelines | |
run: | | |
echo "Terraform plan - ${TF_ENV}" | |
bash scripts/terraform-init.sh modernisation-platform | |
terraform -chdir="modernisation-platform" workspace select "core-shared-services-${TF_ENV}" | |
bash scripts/terraform-plan.sh modernisation-platform | |
env: | |
TF_ENV: production | |
deploy-modernisation-platform: | |
if: github.event.ref == 'refs/heads/main' | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
name: Deploy - modernisation-platform pipelines | |
needs: plan-modernisation-platform | |
runs-on: ubuntu-latest | |
environment: | |
name: core-shared-services | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
- name: Set Account Number | |
run: echo "ACCOUNT_NUMBER=$(jq -r -e '.modernisation_platform_account_id' <<< $ENVIRONMENT_MANAGEMENT)" >> $GITHUB_ENV | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0 | |
with: | |
role-to-assume: "arn:aws:iam::${{ env.ACCOUNT_NUMBER }}:role/github-actions" | |
role-session-name: githubactionsrolesession | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Load and Configure Terraform | |
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 | |
with: | |
terraform_version: ~> 1.0 | |
terraform_wrapper: false | |
- name: Terraform apply - modernisation-platform pipelines | |
run: | | |
echo "Terraform apply - ${TF_ENV}" | |
bash scripts/terraform-init.sh modernisation-platform | |
terraform -chdir="modernisation-platform" workspace select "core-shared-services-${TF_ENV}" | |
bash scripts/terraform-apply.sh modernisation-platform | |
env: | |
TF_ENV: production |