-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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: | | ||
|
@@ -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:" | ||
|