fix(ci): update terraform job template

This commit is contained in:
2023-12-12 09:58:43 +02:00
parent 38d87d5dde
commit cbb0fbe4f4
2 changed files with 35 additions and 17 deletions

View File

@@ -14,16 +14,11 @@ on:
ssh-known-hosts:
required: true
type: string
outputs:
tfplanexitcode:
value: ${{ jobs.tf-plan.outputs.tfplanexitcode }}
jobs:
tf-plan:
name: Terraform Plan
runs-on: ubuntu-latest
outputs:
tfplanexitcode: ${{ steps.tfplan.outputs.exitcode }}
steps:
- uses: hashicorp/setup-terraform@v2
@@ -73,17 +68,21 @@ jobs:
shell: bash
run: |
terraform plan -detailed-exitcode -out=tfplan.binary -input=false;
printf "$?" > exitcode;
continue-on-error: true
- name: Check if job errored
if: ${{ steps.tfplan.outputs.exitcode == 1 }}
shell: sh
run: exit 1
- name: Upload terraform plan if diffs are detected
if: ${{ steps.tfplan.outputs.exitcode == 2 }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: tfplan
path: tfplan.binary
name: artifacts
path: |
tfplan.binary
exitcode
- name: Check if job errored
shell: bash
run: |
if [ "$(cat exitcode)" == "1" ]; then
exit 1;
fi
- name: Save terraform cache
uses: actions/cache/save@v3
id: cache-terraform-save