Update Terraform workflow file paths and output handling
- Change single quotes to double quotes in path filters for consistency - Modify command redirection to use > instead of | tee for cleaner output handling - Add explicit cat command to display plan output in logs - Standardize whitespace formatting throughout files
This commit is contained in:
@@ -5,8 +5,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
paths:
|
paths:
|
||||||
- 'terraform/**'
|
- "terraform/**"
|
||||||
- '.gitea/workflows/terraform-*.yml'
|
- ".gitea/workflows/terraform-*.yml"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TF_WORKING_DIR: terraform/prod
|
TF_WORKING_DIR: terraform/prod
|
||||||
@@ -89,16 +89,17 @@ jobs:
|
|||||||
id: plan
|
id: plan
|
||||||
run: |
|
run: |
|
||||||
set +e
|
set +e
|
||||||
terraform plan -input=false -no-color -detailed-exitcode -out=tfplan 2>&1 | tee plan_output.txt
|
terraform plan -input=false -no-color -detailed-exitcode -out=tfplan > plan_output.txt 2>&1
|
||||||
EXITCODE=$?
|
EXITCODE=$?
|
||||||
|
cat plan_output.txt
|
||||||
|
|
||||||
# Determine if there are changes
|
# Determine if there are changes
|
||||||
if [ $EXITCODE -eq 2 ]; then
|
if [ $EXITCODE -eq 2 ]; then
|
||||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Exit 1 is error, 0 and 2 are OK
|
# Exit 1 is error, 0 and 2 are OK
|
||||||
if [ $EXITCODE -eq 1 ]; then
|
if [ $EXITCODE -eq 1 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
paths:
|
paths:
|
||||||
- 'terraform/**'
|
- "terraform/**"
|
||||||
- '.gitea/workflows/terraform-*.yml'
|
- ".gitea/workflows/terraform-*.yml"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TF_WORKING_DIR: terraform/prod
|
TF_WORKING_DIR: terraform/prod
|
||||||
@@ -87,8 +87,9 @@ jobs:
|
|||||||
id: plan
|
id: plan
|
||||||
run: |
|
run: |
|
||||||
set +e
|
set +e
|
||||||
terraform plan -input=false -no-color -detailed-exitcode -out=tfplan 2>&1 | tee plan_output.txt
|
terraform plan -input=false -no-color -detailed-exitcode -out=tfplan > plan_output.txt 2>&1
|
||||||
EXITCODE=$?
|
EXITCODE=$?
|
||||||
|
cat plan_output.txt
|
||||||
echo "exitcode=${EXITCODE}" >> $GITHUB_OUTPUT
|
echo "exitcode=${EXITCODE}" >> $GITHUB_OUTPUT
|
||||||
if [ $EXITCODE -eq 1 ]; then
|
if [ $EXITCODE -eq 1 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
@@ -116,22 +117,22 @@ jobs:
|
|||||||
PLAN_OUTPUT=$(cat plan_output.txt | head -c 60000)
|
PLAN_OUTPUT=$(cat plan_output.txt | head -c 60000)
|
||||||
COMMENT_BODY=$(cat <<EOF
|
COMMENT_BODY=$(cat <<EOF
|
||||||
## 🔍 Terraform Plan
|
## 🔍 Terraform Plan
|
||||||
|
|
||||||
**Exit code:** \`${{ steps.plan.outputs.exitcode }}\`
|
**Exit code:** \`${{ steps.plan.outputs.exitcode }}\`
|
||||||
- \`0\` = No changes
|
- \`0\` = No changes
|
||||||
- \`2\` = Changes detected
|
- \`2\` = Changes detected
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Click to expand plan output</summary>
|
<summary>Click to expand plan output</summary>
|
||||||
|
|
||||||
\`\`\`hcl
|
\`\`\`hcl
|
||||||
${PLAN_OUTPUT}
|
${PLAN_OUTPUT}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token ${GIT_TOKEN}" \
|
-H "Authorization: token ${GIT_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
|
|||||||
Reference in New Issue
Block a user