mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-17 17:02:36 +00:00
Merge ec7f248c65 into 92e4d08fe1
This commit is contained in:
commit
e03e8ced80
4 changed files with 43 additions and 3 deletions
7
.github/workflows/data/failure/main.tf
vendored
Normal file
7
.github/workflows/data/failure/main.tf
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
resource "random_pet" "pet" {
|
||||||
|
1invalid_key= ""
|
||||||
|
}
|
||||||
|
|
||||||
|
output "pet" {
|
||||||
|
value = random_pet.pet.id
|
||||||
|
}
|
||||||
33
.github/workflows/setup-terraform.yml
vendored
33
.github/workflows/setup-terraform.yml
vendored
|
|
@ -270,7 +270,38 @@ jobs:
|
||||||
|
|
||||||
- name: Terraform Plan
|
- name: Terraform Plan
|
||||||
id: plan
|
id: plan
|
||||||
run: terraform plan
|
run: terraform plan -detailed-exitcode
|
||||||
|
|
||||||
|
- name: Print Terraform Plan
|
||||||
|
run: echo "${{ steps.plan.outputs.stdout }}"
|
||||||
|
|
||||||
|
terraform-run-local-failures:
|
||||||
|
name: 'Terraform Run Local Failures'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
working-directory: ./.github/workflows/data/failure
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup Terraform
|
||||||
|
uses: ./
|
||||||
|
|
||||||
|
# coerce initial command exit code in order to verify it did fail
|
||||||
|
- name: Terraform Init
|
||||||
|
run: terraform init || $(exit 10) && $(exit 1) || [ $? -eq 10 ]
|
||||||
|
|
||||||
|
- name: Terraform Format
|
||||||
|
run: terraform fmt -check || $(exit 10) && $(exit 1) || [ $? -eq 10 ]
|
||||||
|
|
||||||
|
- name: Terraform Plan
|
||||||
|
id: plan
|
||||||
|
run: terraform plan -detailed-exitcode || $(exit 10) && $(exit 1) || [ $? -eq 10 ]
|
||||||
|
|
||||||
- name: Print Terraform Plan
|
- name: Print Terraform Plan
|
||||||
run: echo "${{ steps.plan.outputs.stdout }}"
|
run: echo "${{ steps.plan.outputs.stdout }}"
|
||||||
|
|
|
||||||
3
dist/index1.js
vendored
3
dist/index1.js
vendored
|
|
@ -28012,7 +28012,8 @@ async function checkTerraform () {
|
||||||
core.setOutput('stderr', stderr.contents);
|
core.setOutput('stderr', stderr.contents);
|
||||||
core.setOutput('exitcode', exitCode.toString(10));
|
core.setOutput('exitcode', exitCode.toString(10));
|
||||||
|
|
||||||
if (exitCode === 0 || exitCode === 2) {
|
const usingDetailedExitcode = args.filter(arg => arg.toLowerCase().endsWith('-detailed-exitcode')).length > 0;
|
||||||
|
if (exitCode === 0 || (exitCode === 2 && usingDetailedExitcode)) {
|
||||||
// A exitCode of 0 is considered a success
|
// A exitCode of 0 is considered a success
|
||||||
// An exitCode of 2 may be returned when the '-detailed-exitcode' option
|
// An exitCode of 2 may be returned when the '-detailed-exitcode' option
|
||||||
// is passed to plan. This denotes Success with non-empty
|
// is passed to plan. This denotes Success with non-empty
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ async function checkTerraform () {
|
||||||
core.setOutput('stderr', stderr.contents);
|
core.setOutput('stderr', stderr.contents);
|
||||||
core.setOutput('exitcode', exitCode.toString(10));
|
core.setOutput('exitcode', exitCode.toString(10));
|
||||||
|
|
||||||
if (exitCode === 0 || exitCode === 2) {
|
const usingDetailedExitcode = args.filter(arg => arg.toLowerCase().endsWith('-detailed-exitcode')).length > 0;
|
||||||
|
if (exitCode === 0 || (exitCode === 2 && usingDetailedExitcode)) {
|
||||||
// A exitCode of 0 is considered a success
|
// A exitCode of 0 is considered a success
|
||||||
// An exitCode of 2 may be returned when the '-detailed-exitcode' option
|
// An exitCode of 2 may be returned when the '-detailed-exitcode' option
|
||||||
// is passed to plan. This denotes Success with non-empty
|
// is passed to plan. This denotes Success with non-empty
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue