From fdc40abd67ec850f4fc14837614c19786e597d26 Mon Sep 17 00:00:00 2001 From: Steve Fulmer Date: Thu, 2 Jul 2026 13:53:51 -0400 Subject: [PATCH 1/2] ci: add Slack PR notification workflow Add GitHub Actions workflow that sends Slack notifications on PR events (opened, closed/merged, reopened, and reviews). Uses the proven workflow from openshift_virtualization_ops. Requires SLACK_WEBHOOK_URL repo secret. --- .github/workflows/slack-pr-notifications.yml | 70 ++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/slack-pr-notifications.yml diff --git a/.github/workflows/slack-pr-notifications.yml b/.github/workflows/slack-pr-notifications.yml new file mode 100644 index 0000000..ad25ba8 --- /dev/null +++ b/.github/workflows/slack-pr-notifications.yml @@ -0,0 +1,70 @@ +name: Slack PR Notifications + +on: + pull_request: + types: [opened, closed, reopened] + branches: ["main"] + pull_request_review: + types: [submitted] + +permissions: {} + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: Set notification details + id: details + env: + EVENT_NAME: ${{ github.event_name }} + REVIEW_STATE: ${{ github.event.review.state }} + PR_TITLE: ${{ github.event.pull_request.title }} + REVIEW_USER_LOGIN: ${{ github.event.review.user.login }} + EVENT_ACTION: ${{ github.event.action }} + PR_MERGED: ${{ github.event.pull_request.merged }} + PR_USER_LOGIN: ${{ github.event.pull_request.user.login }} + PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} + PR_BASE_REF: ${{ github.event.pull_request.base.ref }} + PR_URL: ${{ github.event.pull_request.html_url }} + REPO_NAME: ${{ github.repository }} + run: | + if [[ "$EVENT_NAME" == "pull_request_review" ]]; then + STATE="$REVIEW_STATE" + TITLE="PR Review: ${STATE} - ${PR_TITLE}" + COLOR=$([[ "$STATE" == "approved" ]] && echo "good" || echo "warning") + BODY="${REVIEW_USER_LOGIN} ${STATE} the PR" + else + ACTION="$EVENT_ACTION" + TITLE="PR ${ACTION^}: ${PR_TITLE}" + if [[ "$ACTION" == "closed" && "$PR_MERGED" == "true" ]]; then + TITLE="PR Merged: ${PR_TITLE}" + COLOR="good" + elif [[ "$ACTION" == "opened" ]]; then + COLOR="#1a73e8" + elif [[ "$ACTION" == "reopened" ]]; then + COLOR="warning" + else + COLOR="danger" + fi + BODY="${PR_USER_LOGIN} ${ACTION} the PR" + fi + + # Build the Slack message text safely + MSG="*${TITLE}*\n${BODY}\n*Repo:* \`${REPO_NAME}\`\n*Branch:* \`${PR_HEAD_REF}\` -> \`${PR_BASE_REF}\`\n<${PR_URL}|View Pull Request>" + + # Use JSON-safe encoding via jq to prevent injection + { + echo "payload<> "$GITHUB_OUTPUT" + + - name: Send Slack notification + uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52 # v2.1.0 + with: + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + webhook-type: incoming-webhook + payload: ${{ steps.details.outputs.payload }} From 2c34924f7467f837fe73a31aaec87b1ce81636d2 Mon Sep 17 00:00:00 2001 From: Lucas Burigo <281664+burigolucas@users.noreply.github.com> Date: Tue, 7 Jul 2026 15:46:15 +0200 Subject: [PATCH 2/2] skip notification for PR review comments --- .github/workflows/slack-pr-notifications.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/slack-pr-notifications.yml b/.github/workflows/slack-pr-notifications.yml index ad25ba8..d910c67 100644 --- a/.github/workflows/slack-pr-notifications.yml +++ b/.github/workflows/slack-pr-notifications.yml @@ -30,6 +30,11 @@ jobs: run: | if [[ "$EVENT_NAME" == "pull_request_review" ]]; then STATE="$REVIEW_STATE" + # Skip comment-only reviews + if [[ -z "$STATE" ]]; then + echo "Skipping notification for comment-only review" + exit 0 + fi TITLE="PR Review: ${STATE} - ${PR_TITLE}" COLOR=$([[ "$STATE" == "approved" ]] && echo "good" || echo "warning") BODY="${REVIEW_USER_LOGIN} ${STATE} the PR"