Skip to content

Merge pull request #1061 from ministryofjustice/AntonyBishop-patch-1 #185

Merge pull request #1061 from ministryofjustice/AntonyBishop-patch-1

Merge pull request #1061 from ministryofjustice/AntonyBishop-patch-1 #185

name: terraform apply (management-account)
on:
push:
paths:
- "management-account/terraform/**"
- "modules/**"
- ".github/workflows/management-account-plan.yml"
- ".github/workflows/management-account-apply.yml"
branches:
- main
jobs:
apply:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
defaults:
run:
working-directory: ./management-account/terraform
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
role-to-assume: arn:aws:iam::${{secrets.AWS_ROOT_ACCOUNT_ID}}:role/github-actions-apply
role-session-name: GitHubActions
aws-region: eu-west-2
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.7.5
- run: terraform fmt -check
continue-on-error: true
- run: terraform init
- run: terraform validate -no-color
- run: terraform plan -no-color
- run: terraform apply -auto-approve
if: github.event.ref == 'refs/heads/main'
- name: Slack failure notification
if: ${{ failure() && github.ref == 'refs/heads/main' }}
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":x: *GitHub Workflow Failed!* \n\nA workflow has failed in the repository *<https://github.com/${{ github.repository }}|${{ github.repository }}>*.\n\n*Workflow:* `${{ github.workflow }}`\n*Branch:* `${{ github.ref_name }}`\n*Commit:* `${{ github.sha }}`\n*Author:* `${{ github.event.head_commit.author.name }}`"}},
{
"type": "actions",
"elements":[
{
"type":"button",
"text": {
"type": "plain_text",
"text":"View Workflow"
},
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"style": "primary"
},
{
"type": "button",
"text": {
"type":"plain_text",
"text":"View Commit"
},
"url":"https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK