Merge pull request #5 from FIAP-3SOAT-G15/setup-sonar-code-coverage #2
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: Provision | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- .github/workflows/provision.yml | |
- 'terraform/**' | |
- 'src/**' | |
pull_request: | |
branches: | |
- main | |
paths: | |
- .github/workflows/provision.yml | |
- 'terraform/**' | |
- 'src/**' | |
workflow_dispatch: | |
jobs: | |
provision: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./terraform | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ vars.AWS_IAM_ROLE }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_CLOUD_USER_API_TOKEN }} | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
continue-on-error: true | |
- name: Terraform Init | |
id: init | |
run: terraform init | |
- name: Terraform Validate | |
id: validate | |
run: terraform validate | |
- name: Terraform Plan | |
id: plan | |
run: terraform plan | |
- name: Check Errors | |
if: steps.plan.outcome == 'failure' | |
run: exit 1 | |
- name: Terraform Apply | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: terraform apply -auto-approve -input=false |