Skip to content

Commit

Permalink
feat: yaml linting
Browse files Browse the repository at this point in the history
  • Loading branch information
PriyeshM1 committed Dec 30, 2024
1 parent 1f156ea commit 486ba7c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/terraform-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ jobs:
outputs:
result-auth: ${{ steps.auth.outcome }}
result-init: ${{ steps.init.outcome }}
result-plan: ${{ steps.plan.outcome }}
plan-stdout: ${{ steps.plan.outputs.stdout }}
result-validate: ${{ steps.validate.outcome }}
result-s3-backend-check: ${{ steps.s3-backend-check.outcome }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -118,9 +118,9 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ inputs.aws-region }}
mask-aws-account-id: "no"
role-session-name: ${{ github.event.repository.name }}
role-to-assume: arn:aws:iam::${{ inputs.aws-account-id }}:role/${{ steps.role.outputs.name }}
mask-aws-account-id: "no"
- name: Set terraform-state-key variable
id: state-key
run: |
Expand Down Expand Up @@ -158,22 +158,21 @@ jobs:
- name: Check for drift and set status
id: check-drift
run: |
if grep -q 'No changes' <(terraform -chdir=${{ inputs.terraform-dir }} plan -var-file=$TF_VAR_FILE -no-color -input=false -out=tfplan -lock-timeout=${{ inputs.terraform-lock-timeout }}); then
if grep -q 'No changes' <(terraform -chdir=${{ inputs.terraform-dir }} plan -var-file=$TF_VAR_FILE -no-color -input=false -out=tfplan -lock-timeout=${{ inputs.terraform-lock-timeout }}); then
echo "No drift detected."
echo "::set-output name=DRIFT_STATUS::no-drift"
echo "DRIFT_STATUS=no-drift" >> "$GITHUB_OUTPUT"
else
echo "Drift detected!"
echo "::set-output name=DRIFT_STATUS::drift"
echo "DRIFT_STATUS=drift" >> "$GITHUB_OUTPUT"
exit 1 # Fail if drift is detected
fi
- name: Send Slack notification if drift is detected
if: steps.check-drift.outputs.DRIFT_STATUS == 'drift'
uses: slackapi/[email protected]
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook: ${{ secrets.slack-webhook-url }}
payload: |
{
"channel": "#${{ secrets.SLACK_CHANNEL }}",
"username": "GitHub Actions",
"text": "🚨 Drift Detected (${{ github.repository }})",
"icon_emoji": ":warning:"
Expand Down

0 comments on commit 486ba7c

Please sign in to comment.