Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.sh Secret

Last active July 31, 2024 19:20
Show Gist options
  • Save KyMidd/f0b4bda7299b8ee0b20478588372ac37 to your computer and use it in GitHub Desktop.
Save KyMidd/f0b4bda7299b8ee0b20478588372ac37 to your computer and use it in GitHub Desktop.
if [[ "$TERRAFORM_PLAN_OUTPUT" =~ "infrastructure matches the configuration" ]]; then
echo "There are no changes for terraform to apply."
elif [[ "$TERRAFORM_PLAN_OUTPUT" =~ "will perform the following actions" ]]; then
echo "Drift has been detected, posting notification to Slack room"
# Set vars
REPO_URL=${{ github.server_url }}/${{ github.repository }}
ACTION_RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
# Send drift detection post to slack
curl -sX POST --data-urlencode "payload={\"text\": \"Drift has been detected in <$REPO_URL|${{ github.event.repository.name }}> in env <${ACTION_RUN_URL}|${{ inputs.solution_name }}>.\"}" ${{ inputs.prod_drift_slack_webhook_url }}
else
echo "There was an error detecting if there were changes"
echo "We should investigate what's wrong, or try re-running this workflow"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment