Merge pull request #1 from patrickm663/actuarial #64
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
# CICD to ensure the S3 infrastructure is built correctly | |
name: S3 | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./iac | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
CI_COMMIT_MESSAGE: CICD GitHub Actions build | |
CI_COMMIT_AUTHOR: Continuous Integration | |
permissions: | |
contents: write | |
steps: | |
- name: Setup Actions | |
uses: actions/checkout@v3 | |
- name: Setup AWS | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Setup Terraform CLI | |
uses: hashicorp/[email protected] | |
- name: Get Terraform State | |
run: aws s3 cp ${{ secrets.TF_STATE }} . --recursive | |
- name: Format | |
run: terraform fmt -check | |
continue-on-error: true | |
- name: Initialise | |
run: terraform init | |
- name: Validate | |
run: terraform validate -no-color | |
continue-on-error: true | |
- name: Plan | |
run: terraform validate -no-color | |
continue-on-error: true | |
- name: Apply | |
run: terraform apply -auto-approve | |
- name: Copy State back to S3 | |
run: | | |
aws s3 cp terraform.tfstate ${{ secrets.TF_STATE }} |