Просмотр исходного кода

Separate push notification from pull request

Matthew Mathias 3 лет назад
Родитель
Сommit
be0603ff8a
2 измененных файлов с 60 добавлено и 4 удалено
  1. 0 4
      .github/workflows/pr_notification.yml
  2. 60 0
      .github/workflows/push_notification.yml

+ 0 - 4
.github/workflows/notification.yml → .github/workflows/pr_notification.yml

@@ -3,10 +3,6 @@ name: GSI Chatroom PR Notification
 on:
   pull_request:
     types: [assigned, opened, ready_for_review, reopened, review_requested]
-  push:
-    branches:
-      - main
-    
 
 jobs:
   notify:

+ 60 - 0
.github/workflows/push_notification.yml

@@ -0,0 +1,60 @@
+on:
+  push:
+    branches:
+      - main
+
+jobs:
+  notify:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Main Branch Push
+      run: |
+        echo "Pushing commit to main: ${{ github.event.push.head_commit.id }}"
+        echo "Pushed by: ${{ github.event.push.pusher.name }}"
+
+    - name: Push Notification to Google Chat
+      run: |
+        curl --location --request POST '${{ secrets.WEBHOOK_URL }}' \
+        --header 'Content-Type: application/json' \
+        --data-raw '{
+          "cards": [
+            {
+              "header": {
+                "title": "Push to main branch",
+                "subtitle": "${{ github.event.push.head_commit.message }}"
+              },
+              "sections": [
+                {
+                  "widgets": [
+                    {
+                      "keyValue": {
+                        "topLabel": "Repo",
+                        "content": "${{ github.event.push.repository.name }}"
+                      }
+                    },
+                    {
+                      "keyValue": {
+                        "topLabel": "Committed by",
+                        "content": "Committed by: ${{ github.event.push.head_commit.committer.username }}"
+                      }
+                    },
+                    {
+                      "buttons": [
+                        {
+                          "textButton": {
+                            "text": "Ref comparison",
+                            "onClick": {
+                              "openLink": {
+                                "url": "${{ github.event.push.compare }}"
+                              }
+                            }
+                          }
+                        }
+                      ]
+                    }
+                  ]
+                }
+              ]
+            }
+          ]
+        }'