Skip to content

Merge pull request #816 from wwuoneway/form-redesign-backend-technology #57

Merge pull request #816 from wwuoneway/form-redesign-backend-technology

Merge pull request #816 from wwuoneway/form-redesign-backend-technology #57

name: Guardrail Push Alerts
on:
push:
branches: [main]
jobs:
slack-alert:
runs-on: ubuntu-latest
permissions: {} # Explicitly drops all token permissions
if: github.actor != 'dependabot[bot]'
steps:
- name: Process and Format Slack Alert
env:
SLACK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# Safely map variables as structured environment inputs
COMMIT_MSG: ${{ github.event.head_commit.message }}
COMMITTER: ${{ github.event.head_commit.committer.name }}
REPO_NAME: ${{ github.repository }}
ACTOR: ${{ github.actor }}
run: |
# If the committer isn't 'GitHub', an admin pushed directly via local CLI.
if [ "$COMMITTER" != "GitHub" ]; then
# Use jq to format a completely safe, escaped JSON object for Slack
PAYLOAD=$(jq -n \
--arg msg "$COMMIT_MSG" \
--arg repo "$REPO_NAME" \
--arg actor "$ACTOR" \
'{"text": "⚠️ *Direct Push to Main Detected!*\n*Repo:* `\($repo)`\n*Actor:* `@\($actor)`\n*Commit:* `\($msg)`"}')
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_URL"
fi