Merge pull request #49 from Suprajaa-27/feature/dev #121
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: Terraform CI/CD | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
jobs: | |
terraform: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# OIDC Config | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: arn:aws:iam::388921471165:role/github-to-aws-oidc | |
aws-region: eu-north-1 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
- name: Terraform Init | |
working-directory: ./terraform | |
run: terraform init | |
- name: Terraform Format | |
working-directory: ./terraform | |
run: terraform fmt | |
- name: Terraform Validate | |
working-directory: ./terraform | |
run: terraform validate | |
- name: Terraform Plan | |
working-directory: ./terraform | |
run: terraform plan | |
- name: Terraform Apply | |
working-directory: ./terraform | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: terraform apply -auto-approve | |