made changes #29
This file contains hidden or 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: infra-main | |
| on: | |
| pull_request: | |
| branches: | |
| - infra_main | |
| jobs: | |
| infracost-pull-request-checks: | |
| env: | |
| ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | |
| ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }} | |
| ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
| ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }} | |
| TF_VAR_resource_name: ${{ secrets.TF_VARS_RESOURCE_NAME }} | |
| TF_VAR_location: ${{ secrets.TF_VARS_LOCATION }} | |
| TF_VAR_address_space: ${{ secrets.TF_VARS_ADDRESS_SPACE }} | |
| TF_VAR_address_prefixes: ${{ secrets.TF_VARS_ADDRESS_PREFIXES }} | |
| TF_VAR_vm_size: ${{ secrets.TF_VARS_VM_SIZE }} | |
| TF_VAR_admin_username: ${{ secrets.TF_VARS_ADMIN_USERNAME }} | |
| TF_VAR_ssh_key_path: ${{ secrets.TF_VARS_SSH_KEY_PATH }} | |
| TF_VAR_ssh_pri_key: ${{ secrets.TF_VARS_SSH_PRI_KEY_PATH }} | |
| TF_VAR_dns_password: ${{ secrets.TF_VARS_DNS_PASSWORD }} | |
| name: Infracost PR Checks and terraform plan comment | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Write ssh keys to file | |
| run: | | |
| mkdir -p /home/runner/.ssh | |
| echo "${{ secrets.SSH_PUBLIC_KEY }}" > /home/runner/.ssh/id_rsa.pub | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > /home/runner/.ssh/id_rsa | |
| chmod 600 /home/runner/.ssh/id_rsa | |
| chmod 644 /home/runner/.ssh/id_rsa.pub | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.9.5 | |
| - name: Terraform Init | |
| run: | | |
| cd infrastructure/terraform | |
| terraform init | |
| - name: Terraform plan | |
| run: | | |
| cd infrastructure/terraform | |
| terraform plan -input=false -out=.planfile | |
| - name: Post PR comment | |
| uses: borchero/terraform-plan-comment@v2 | |
| with: | |
| token: ${{ github.token }} | |
| working-directory: ./infrastructure/terraform | |
| planfile: .planfile | |
| - name: Setup Infracost | |
| uses: infracost/actions/setup@v3 | |
| with: | |
| api-key: ${{ secrets.INFRACOST_API_KEY }} | |
| - name: Checkout base branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: '${{ github.event.pull_request.base.ref }}' | |
| - name: Generate Infracost cost estimate baseline | |
| run: | | |
| infracost breakdown --path=infrastructure/terraform \ | |
| --format=json \ | |
| --out-file=/tmp/infracost-base.json | |
| - name: Check infracost files | |
| run: cat /tmp/infracost-base.json | |
| - name: Checkout PR branch | |
| uses: actions/checkout@v4 | |
| - name: Generate Infracost diff | |
| run: | | |
| infracost diff --path=infrastructure/terraform \ | |
| --format=json \ | |
| --compare-to=/tmp/infracost-base.json \ | |
| --out-file=/tmp/infracost.json | |
| - name: Post Infracost comment | |
| run: | | |
| infracost comment github --path=/tmp/infracost.json \ | |
| --repo=$GITHUB_REPOSITORY \ | |
| --github-token=${{ github.token }} \ | |
| --pull-request=${{ github.event.pull_request.number }} \ | |
| --behavior=update |