From 06ec153b796bec7b321b581d7badd5aef79d9e66 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 7 May 2025 05:16:43 +0500 Subject: [PATCH 01/21] Remove unnecessary blank lines for improved readability in README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 89f387c..40b8046 100644 --- a/README.md +++ b/README.md @@ -28,5 +28,3 @@ pnpm create next-app --example with-playwright with-playwright-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). - - From 667c2289caaa977f704e03cdc5214a433e21bf2a Mon Sep 17 00:00:00 2001 From: Beast <105932517+ibrahimAlphaSquad@users.noreply.github.com> Date: Thu, 8 May 2025 19:45:16 +0500 Subject: [PATCH 02/21] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 40b8046..959acc4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -[![Playwright Tests](https://github.com/ibrahimAlphaSquad/playwright/actions/workflows/playwright.yml/badge.svg)](https://github.com/ibrahimAlphaSquad/playwright/actions/workflows/playwright.yml) - - # Next.js + Playwright This example shows how to configure Playwright to work with Next.js. From c4027ead6e7c6d7f1dff55d9b015e60b55740e44 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Thu, 8 May 2025 21:06:02 +0500 Subject: [PATCH 03/21] Add a newline at the end of README.md for better formatting --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 959acc4..0446979 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,4 @@ pnpm create next-app --example with-playwright with-playwright-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). + From 2d239f458e8df034eb6f3f1edb498a50d63df603 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Thu, 8 May 2025 21:43:56 +0500 Subject: [PATCH 04/21] Add newline at the end of README.md for better formatting --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0446979..9e9743f 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,4 @@ pnpm create next-app --example with-playwright with-playwright-app Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). + From a2b34bab92ef55fe6b1b8914d12d2bc2405ac8fa Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Fri, 9 May 2025 02:47:53 +0500 Subject: [PATCH 05/21] Remove unnecessary blank lines for improved readability in README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 9e9743f..959acc4 100644 --- a/README.md +++ b/README.md @@ -25,5 +25,3 @@ pnpm create next-app --example with-playwright with-playwright-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). - - From fad0d3798bc5a8e28212f0e7f1e420759bf902ad Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Fri, 9 May 2025 18:10:06 +0500 Subject: [PATCH 06/21] Add newlines at the end of README.md for better formatting --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 959acc4..9e9743f 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,5 @@ pnpm create next-app --example with-playwright with-playwright-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). + + From a9dd5e680c3da05479ab8ea54b7312066783eb88 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Fri, 9 May 2025 18:17:50 +0500 Subject: [PATCH 07/21] Test --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 9e9743f..959acc4 100644 --- a/README.md +++ b/README.md @@ -25,5 +25,3 @@ pnpm create next-app --example with-playwright with-playwright-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). - - From dfe6709e23b944c2473b2d6df4f148d44508c57d Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Fri, 9 May 2025 18:21:03 +0500 Subject: [PATCH 08/21] Add newlines at the end of README.md for better formatting --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 959acc4..9e9743f 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,5 @@ pnpm create next-app --example with-playwright with-playwright-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). + + From ec52a4976fd14b212cda6d722147c4b8f9551731 Mon Sep 17 00:00:00 2001 From: Beast <105932517+ibrahimAlphaSquad@users.noreply.github.com> Date: Mon, 12 May 2025 18:15:09 +0500 Subject: [PATCH 09/21] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 9e9743f..959acc4 100644 --- a/README.md +++ b/README.md @@ -25,5 +25,3 @@ pnpm create next-app --example with-playwright with-playwright-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). - - From 28b2d2bbda36e8df4b89d93ee26ab40e6ecb91e5 Mon Sep 17 00:00:00 2001 From: Beast <105932517+ibrahimAlphaSquad@users.noreply.github.com> Date: Fri, 30 May 2025 20:52:47 +0500 Subject: [PATCH 10/21] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 959acc4..a6910d2 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,6 @@ pnpm create next-app --example with-playwright with-playwright-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). + + + From cee7ca6a1a2b8e613f28ae0708976f39f021b9e0 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 19:28:27 +0500 Subject: [PATCH 11/21] feat: add Slack notifications for various PR events with detailed messaging --- .github/workflows/{slack-notify.yml => slack-notify} | 0 ...-notify-incoming-webhook.yml => slack-notify-incoming-webhook} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{slack-notify.yml => slack-notify} (100%) rename .github/workflows/{slack-notify-incoming-webhook.yml => slack-notify-incoming-webhook} (100%) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify similarity index 100% rename from .github/workflows/slack-notify.yml rename to .github/workflows/slack-notify diff --git a/.github/workflows/slack-notify-incoming-webhook.yml b/.github/workflows/slack-notify-incoming-webhook similarity index 100% rename from .github/workflows/slack-notify-incoming-webhook.yml rename to .github/workflows/slack-notify-incoming-webhook From 27e655bdb9b70e7ecad09765d6b62196bdd9ed19 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 19:29:42 +0500 Subject: [PATCH 12/21] feat: implement Slack notifications for PR events with message formatting --- .github/scripts/send_to_slack.py | 46 ++++++++++++++++++++++++++ .github/scripts/slack_utils.py | 26 +++++++++++++++ .github/scripts/thread_tracker.py | 17 ++++++++++ .github/workflows/slack-notify-v2.yml | 47 +++++++++++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 .github/scripts/send_to_slack.py create mode 100644 .github/scripts/slack_utils.py create mode 100644 .github/scripts/thread_tracker.py create mode 100644 .github/workflows/slack-notify-v2.yml diff --git a/.github/scripts/send_to_slack.py b/.github/scripts/send_to_slack.py new file mode 100644 index 0000000..48a2f58 --- /dev/null +++ b/.github/scripts/send_to_slack.py @@ -0,0 +1,46 @@ +import os +import json +import requests +from slack_utils import search_slack_thread + +def main(): + pr_number = os.getenv("NUMBER") + is_new_pr = os.getenv("IS_NEW_PR") == "true" + thread_key = os.getenv("THREAD_KEY") + channel = os.getenv("SLACK_CHANNEL") + slack_token = os.getenv("SLACK_USER_OAUTH_TOKEN") # must be set as secret + + # For non-new PRs: find original thread via Slack search + thread_ts = None + if not is_new_pr: + thread_ts = search_slack_thread(slack_token, channel, thread_key) + + payload = { + "channel": channel, + "attachments": [ + { + "color": os.getenv("COLOR", "#cccccc"), + "pretext": f"*{os.getenv('GITHUB_REPOSITORY')}*", + "title": f"{os.getenv('TITLE')} #{pr_number}", + "title_link": os.getenv("TITLE_LINK"), + "text": os.getenv("MESSAGE"), + "footer": f"GitHub Actions • Thread-Key: {thread_key}", + "footer_icon": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", + "mrkdwn_in": ["text", "pretext", "footer"], + "ts": os.getenv("TIMESTAMP") + } + ] + } + + if thread_ts: + payload["thread_ts"] = thread_ts + + webhook_url = os.getenv("SLACK_INCOMING_WEBHOOK_URL") + response = requests.post(webhook_url, json=payload) + + if response.status_code != 200: + print("Slack response:", response.text) + raise Exception("Failed to send Slack message") + +if __name__ == "__main__": + main() diff --git a/.github/scripts/slack_utils.py b/.github/scripts/slack_utils.py new file mode 100644 index 0000000..05ed54d --- /dev/null +++ b/.github/scripts/slack_utils.py @@ -0,0 +1,26 @@ +import os +import requests +import json + +def search_slack_thread(slack_token, channel, thread_key): + query = f'in:{channel} "{thread_key}"' + response = requests.post( + "https://slack.com/api/search.messages", + headers={"Authorization": f"Bearer {slack_token}"}, + data={ + "query": query, + "sort": "timestamp", + "sort_dir": "asc", + "count": "1" + } + ) + + if response.status_code != 200: + raise Exception(f"Slack API error: {response.text}") + + data = response.json() + matches = data.get("messages", {}).get("matches", []) + + if matches: + return matches[0].get("ts") # thread_ts of the original message + return None diff --git a/.github/scripts/thread_tracker.py b/.github/scripts/thread_tracker.py new file mode 100644 index 0000000..b6e8a89 --- /dev/null +++ b/.github/scripts/thread_tracker.py @@ -0,0 +1,17 @@ +import os +import json + +def thread_file_path(pr_number): + return f".slack-threads/pr-{pr_number}.json" + +def save_thread_ts(pr_number, thread_ts): + os.makedirs(".slack-threads", exist_ok=True) + with open(thread_file_path(pr_number), "w") as f: + json.dump({"thread_ts": thread_ts}, f) + +def get_thread_ts(pr_number): + try: + with open(thread_file_path(pr_number), "r") as f: + return json.load(f)["thread_ts"] + except FileNotFoundError: + return None diff --git a/.github/workflows/slack-notify-v2.yml b/.github/workflows/slack-notify-v2.yml new file mode 100644 index 0000000..16d0215 --- /dev/null +++ b/.github/workflows/slack-notify-v2.yml @@ -0,0 +1,47 @@ +name: Slack PR Notifications + +on: + pull_request: + types: [opened, closed, reopened, synchronize, edited, assigned, unassigned] + pull_request_review: + types: [submitted] + pull_request_review_comment: + types: [created] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: false + +env: + SLACK_CHANNEL: alpha-pr-review + SLACK_API_URL: 'https://slack.com/api/chat.postMessage' + SLACK_CHANNEL_ID: "C08R6EB1DEU" + +jobs: + notify: + runs-on: ubuntu-latest + + steps: + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install dependencies + run: pip install requests + + - name: Send Slack notification + run: python scripts/send_to_slack.py + env: + SLACK_INCOMING_WEBHOOK_URL: ${{ vars.SLACK_INCOMING_WEBHOOK_URL }} + SLACK_USER_OAUTH_TOKEN: ${{ secrets.SLACK_USER_OAUTH_TOKEN }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + SLACK_CHANNEL_ID: ${{ env.SLACK_CHANNEL_ID }} + MESSAGE: ${{ env.MESSAGE }} + COLOR: ${{ env.COLOR }} + THREAD_KEY: ${{ env.THREAD_KEY }} + TITLE: ${{ env.TITLE }} + TITLE_LINK: ${{ env.TITLE_LINK }} + NUMBER: ${{ env.NUMBER }} + TIMESTAMP: ${{ env.TIMESTAMP }} + IS_NEW_PR: ${{ github.event.action == 'opened' && 'true' || 'false' }} + From 06e4a90ceb1d2ce1e55e4e6400b17761ea6eeb63 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 19:30:52 +0500 Subject: [PATCH 13/21] chore: remove unnecessary blank lines from README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 3aa88dd..9e9743f 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,3 @@ pnpm create next-app --example with-playwright with-playwright-app Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). - - From 74a3aa54c71c81d6091c3438f3d098dcc6daf3f4 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 19:36:13 +0500 Subject: [PATCH 14/21] changes --- .github/scripts/send_to_slack.py | 46 ------------------------------- .github/scripts/slack_utils.py | 26 ----------------- .github/scripts/thread_tracker.py | 17 ------------ 3 files changed, 89 deletions(-) delete mode 100644 .github/scripts/send_to_slack.py delete mode 100644 .github/scripts/slack_utils.py delete mode 100644 .github/scripts/thread_tracker.py diff --git a/.github/scripts/send_to_slack.py b/.github/scripts/send_to_slack.py deleted file mode 100644 index 48a2f58..0000000 --- a/.github/scripts/send_to_slack.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import json -import requests -from slack_utils import search_slack_thread - -def main(): - pr_number = os.getenv("NUMBER") - is_new_pr = os.getenv("IS_NEW_PR") == "true" - thread_key = os.getenv("THREAD_KEY") - channel = os.getenv("SLACK_CHANNEL") - slack_token = os.getenv("SLACK_USER_OAUTH_TOKEN") # must be set as secret - - # For non-new PRs: find original thread via Slack search - thread_ts = None - if not is_new_pr: - thread_ts = search_slack_thread(slack_token, channel, thread_key) - - payload = { - "channel": channel, - "attachments": [ - { - "color": os.getenv("COLOR", "#cccccc"), - "pretext": f"*{os.getenv('GITHUB_REPOSITORY')}*", - "title": f"{os.getenv('TITLE')} #{pr_number}", - "title_link": os.getenv("TITLE_LINK"), - "text": os.getenv("MESSAGE"), - "footer": f"GitHub Actions • Thread-Key: {thread_key}", - "footer_icon": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", - "mrkdwn_in": ["text", "pretext", "footer"], - "ts": os.getenv("TIMESTAMP") - } - ] - } - - if thread_ts: - payload["thread_ts"] = thread_ts - - webhook_url = os.getenv("SLACK_INCOMING_WEBHOOK_URL") - response = requests.post(webhook_url, json=payload) - - if response.status_code != 200: - print("Slack response:", response.text) - raise Exception("Failed to send Slack message") - -if __name__ == "__main__": - main() diff --git a/.github/scripts/slack_utils.py b/.github/scripts/slack_utils.py deleted file mode 100644 index 05ed54d..0000000 --- a/.github/scripts/slack_utils.py +++ /dev/null @@ -1,26 +0,0 @@ -import os -import requests -import json - -def search_slack_thread(slack_token, channel, thread_key): - query = f'in:{channel} "{thread_key}"' - response = requests.post( - "https://slack.com/api/search.messages", - headers={"Authorization": f"Bearer {slack_token}"}, - data={ - "query": query, - "sort": "timestamp", - "sort_dir": "asc", - "count": "1" - } - ) - - if response.status_code != 200: - raise Exception(f"Slack API error: {response.text}") - - data = response.json() - matches = data.get("messages", {}).get("matches", []) - - if matches: - return matches[0].get("ts") # thread_ts of the original message - return None diff --git a/.github/scripts/thread_tracker.py b/.github/scripts/thread_tracker.py deleted file mode 100644 index b6e8a89..0000000 --- a/.github/scripts/thread_tracker.py +++ /dev/null @@ -1,17 +0,0 @@ -import os -import json - -def thread_file_path(pr_number): - return f".slack-threads/pr-{pr_number}.json" - -def save_thread_ts(pr_number, thread_ts): - os.makedirs(".slack-threads", exist_ok=True) - with open(thread_file_path(pr_number), "w") as f: - json.dump({"thread_ts": thread_ts}, f) - -def get_thread_ts(pr_number): - try: - with open(thread_file_path(pr_number), "r") as f: - return json.load(f)["thread_ts"] - except FileNotFoundError: - return None From 34f8684963dea486092279cebbcae908a2e23005 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 19:37:43 +0500 Subject: [PATCH 15/21] changes --- .github/workflows/slack-notify-v2.yml | 83 +++++++++++++++++++++------ 1 file changed, 65 insertions(+), 18 deletions(-) diff --git a/.github/workflows/slack-notify-v2.yml b/.github/workflows/slack-notify-v2.yml index 16d0215..e245bca 100644 --- a/.github/workflows/slack-notify-v2.yml +++ b/.github/workflows/slack-notify-v2.yml @@ -2,11 +2,24 @@ name: Slack PR Notifications on: pull_request: - types: [opened, closed, reopened, synchronize, edited, assigned, unassigned] + types: + - opened + - closed + - reopened + - synchronize + - edited + - assigned + - unassigned + - labeled + - unlabeled + - converted_to_draft + - ready_for_review + - review_requested + - review_request_removed pull_request_review: - types: [submitted] + types: [submitted, edited, dismissed] pull_request_review_comment: - types: [created] + types: [created, edited, deleted] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} @@ -22,26 +35,60 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.11' + - name: Install dependencies run: pip install requests - + + - name: Set environment variables for Slack + run: | + ACTION="${{ github.event.action }}" + IS_NEW_PR=false + if [[ "$GITHUB_EVENT_NAME" == "pull_request" && "$ACTION" == "opened" ]]; then + IS_NEW_PR=true + fi + + echo "IS_NEW_PR=$IS_NEW_PR" >> $GITHUB_ENV + echo "MESSAGE=GitHub Event: $GITHUB_EVENT_NAME, Action: $ACTION" >> $GITHUB_ENV + echo "COLOR=#28a745" >> $GITHUB_ENV + + if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then + echo "THREAD_KEY=${{ github.repository }}-pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV + echo "TITLE=${{ github.event.pull_request.title }}" >> $GITHUB_ENV + echo "TITLE_LINK=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV + echo "NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV + elif [[ "$GITHUB_EVENT_NAME" == "pull_request_review" ]]; then + echo "THREAD_KEY=${{ github.repository }}-pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV + echo "TITLE=${{ github.event.pull_request.title }}" >> $GITHUB_ENV + echo "TITLE_LINK=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV + echo "NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV + elif [[ "$GITHUB_EVENT_NAME" == "pull_request_review_comment" ]]; then + echo "THREAD_KEY=${{ github.repository }}-pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV + echo "TITLE=${{ github.event.pull_request.title }}" >> $GITHUB_ENV + echo "TITLE_LINK=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV + echo "NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV + fi + + echo "TIMESTAMP=$(date +%s)" >> $GITHUB_ENV + - name: Send Slack notification run: python scripts/send_to_slack.py env: - SLACK_INCOMING_WEBHOOK_URL: ${{ vars.SLACK_INCOMING_WEBHOOK_URL }} - SLACK_USER_OAUTH_TOKEN: ${{ secrets.SLACK_USER_OAUTH_TOKEN }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} - SLACK_CHANNEL_ID: ${{ env.SLACK_CHANNEL_ID }} - MESSAGE: ${{ env.MESSAGE }} - COLOR: ${{ env.COLOR }} - THREAD_KEY: ${{ env.THREAD_KEY }} - TITLE: ${{ env.TITLE }} - TITLE_LINK: ${{ env.TITLE_LINK }} - NUMBER: ${{ env.NUMBER }} - TIMESTAMP: ${{ env.TIMESTAMP }} - IS_NEW_PR: ${{ github.event.action == 'opened' && 'true' || 'false' }} - + SLACK_INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} + SLACK_USER_OAUTH_TOKEN: ${{ secrets.SLACK_USER_OAUTH_TOKEN }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + SLACK_CHANNEL_ID: ${{ env.SLACK_CHANNEL_ID }} + MESSAGE: ${{ env.MESSAGE }} + COLOR: ${{ env.COLOR }} + THREAD_KEY: ${{ env.THREAD_KEY }} + TITLE: ${{ env.TITLE }} + TITLE_LINK: ${{ env.TITLE_LINK }} + NUMBER: ${{ env.NUMBER }} + TIMESTAMP: ${{ env.TIMESTAMP }} + IS_NEW_PR: ${{ env.IS_NEW_PR }} From 0659cec0f6d669d86830e6d51964ea2d610ef56c Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 20:06:38 +0500 Subject: [PATCH 16/21] fix: ensure SLACK_INCOMING_WEBHOOK_URL is set and clean up imports in slack_utils.py --- scripts/send_to_slack.py | 5 ++++- scripts/slack_utils.py | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/send_to_slack.py b/scripts/send_to_slack.py index 48a2f58..81d4602 100644 --- a/scripts/send_to_slack.py +++ b/scripts/send_to_slack.py @@ -8,7 +8,7 @@ def main(): is_new_pr = os.getenv("IS_NEW_PR") == "true" thread_key = os.getenv("THREAD_KEY") channel = os.getenv("SLACK_CHANNEL") - slack_token = os.getenv("SLACK_USER_OAUTH_TOKEN") # must be set as secret + slack_token = os.getenv("SLACK_USER_OAUTH_TOKEN") # For non-new PRs: find original thread via Slack search thread_ts = None @@ -36,6 +36,9 @@ def main(): payload["thread_ts"] = thread_ts webhook_url = os.getenv("SLACK_INCOMING_WEBHOOK_URL") + if not webhook_url: + raise Exception("Missing SLACK_INCOMING_WEBHOOK_URL environment variable") + response = requests.post(webhook_url, json=payload) if response.status_code != 200: diff --git a/scripts/slack_utils.py b/scripts/slack_utils.py index 05ed54d..70e7c00 100644 --- a/scripts/slack_utils.py +++ b/scripts/slack_utils.py @@ -1,6 +1,4 @@ -import os import requests -import json def search_slack_thread(slack_token, channel, thread_key): query = f'in:{channel} "{thread_key}"' From 22cd8eee4312d1cc957948804091126a056f8307 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 20:07:36 +0500 Subject: [PATCH 17/21] chore: add spacing for improved readability in README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9e9743f..3aa88dd 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,5 @@ pnpm create next-app --example with-playwright with-playwright-app Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). + + From 19271fc99e6846be3b1bef917849959afba106c3 Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 20:10:49 +0500 Subject: [PATCH 18/21] chore: define environment for Slack notification job in workflow --- .github/workflows/slack-notify-v2.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/slack-notify-v2.yml b/.github/workflows/slack-notify-v2.yml index e245bca..823550e 100644 --- a/.github/workflows/slack-notify-v2.yml +++ b/.github/workflows/slack-notify-v2.yml @@ -32,6 +32,8 @@ env: jobs: notify: + environment: + name: Production runs-on: ubuntu-latest steps: From 521f007e3d55c143c7f7c52e1c2bc737c83fcb8b Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 20:14:21 +0500 Subject: [PATCH 19/21] changes --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 3aa88dd..9e9743f 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,3 @@ pnpm create next-app --example with-playwright with-playwright-app Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). - - From 45fc29999a0649e7729c3551173e783c48b8060f Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Wed, 2 Jul 2025 20:21:54 +0500 Subject: [PATCH 20/21] chore: enhance Slack notification workflow to include discussion events and improve concurrency group --- .github/workflows/slack-notify-v2.yml | 29 ++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/slack-notify-v2.yml b/.github/workflows/slack-notify-v2.yml index 823550e..c93cc3f 100644 --- a/.github/workflows/slack-notify-v2.yml +++ b/.github/workflows/slack-notify-v2.yml @@ -17,12 +17,30 @@ on: - review_requested - review_request_removed pull_request_review: - types: [submitted, edited, dismissed] + types: + - submitted + - edited + - dismissed pull_request_review_comment: - types: [created, edited, deleted] + types: + - created + - edited + - deleted + discussion: + types: + - created + - edited + - deleted + - answered + - unanswered + discussion_comment: + types: + - created + - edited + - deleted concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.sha }}-${{ github.run_id }} cancel-in-progress: false env: @@ -75,6 +93,11 @@ jobs: echo "TITLE=${{ github.event.pull_request.title }}" >> $GITHUB_ENV echo "TITLE_LINK=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV echo "NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV + elif [[ "$GITHUB_EVENT_NAME" == "discussion" || "$GITHUB_EVENT_NAME" == "discussion_comment" ]]; then + echo "THREAD_KEY=${{ github.repository }}-discussion-${{ github.event.discussion.number }}" >> $GITHUB_ENV + echo "TITLE=${{ github.event.discussion.title }}" >> $GITHUB_ENV + echo "TITLE_LINK=${{ github.event.discussion.html_url }}" >> $GITHUB_ENV + echo "NUMBER=${{ github.event.discussion.number }}" >> $GITHUB_ENV fi echo "TIMESTAMP=$(date +%s)" >> $GITHUB_ENV From baa68129201b0f3f87238349a8ab42cf5880a2dd Mon Sep 17 00:00:00 2001 From: ibrahimAlphaSquad Date: Fri, 4 Jul 2025 21:01:41 +0500 Subject: [PATCH 21/21] chore: add ZAP scan job to auto-tag workflow and create directory structure documentation --- .github/workflows/auto-tag.yml | 41 ++++++++++++++++++++++++++++++++-- Directory Structure | 18 +++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 Directory Structure diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index 64ea553..b381ffb 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -15,10 +15,48 @@ permissions: pull-requests: read jobs: + zap_scan: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Create directories for ZAP + run: | + mkdir -p zap-reports zap-home + chmod -R 777 zap-reports zap-home # Ensure write permissions + + - name: Run ZAP scan + run: | + echo "Starting ZAP scan..." + docker run -v $(pwd)/zap-reports:/zap/wrk:rw -v $(pwd)/zap-home:/zap/.ZAP:rw ghcr.io/zaproxy/zaproxy:stable zap.sh -cmd -quickurl https://your-target-app.com -quickout /zap/wrk/report.html + echo "ZAP scan completed" + ls -la zap-reports/ + + - name: Check ZAP scan results + run: | + echo "=== ZAP Scan Results ===" + ls -la zap-reports/ + if [ -f zap-reports/report.html ]; then + echo "HTML report generated successfully" + else + echo "Warning: HTML report not found" + fi + + - name: Upload ZAP scan reports + uses: actions/upload-artifact@v4 + with: + name: zap-scan-reports-50 + path: zap-reports/ + if-no-files-found: warn + retention-days: 30 + compression-level: 6 + overwrite: false + include-hidden-files: false + tag_on_pr_merge: if: github.event_name == 'pull_request' && github.event.pull_request.merged == true runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 @@ -86,7 +124,6 @@ jobs: tag_on_direct_push: if: github.event_name == 'push' && github.actor != 'web-flow' runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/Directory Structure b/Directory Structure new file mode 100644 index 0000000..9dfa329 --- /dev/null +++ b/Directory Structure @@ -0,0 +1,18 @@ +# Directory Structure +# ------------------- +# .github/ +# ├── workflows/ +# │ └── slack-notify-v2.yml +# scripts/ +# ├── send_to_slack.py +# ├── slack_utils.py +# └── thread_tracker.py + +# File: scripts/send_to_slack.py + +# File: scripts/slack_utils.py + +# File: scripts/thread_tracker.py (not used in current flow, optional for local fallback) + + +# File: .github/workflows/slack-notify-v2.yml