Repository navigation
Simplify EMM Tests #492
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: GSI Chatroom PR Notification | |
| on: | |
| pull_request: | |
| types: [review_requested] | |
| permissions: | |
| contents: read | |
| jobs: | |
| notify-pull-request: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Pull Request Details | |
| run: | | |
| echo "Pull Request: ${PR_NUMBER}" | |
| echo "Author: ${AUTHOR}" | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| AUTHOR: ${{ github.event.pull_request.user.login }} | |
| - name: Google Chat Notification | |
| continue-on-error: true | |
| shell: bash | |
| env: | |
| WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| TITLE: ${{ github.event.pull_request.title }} | |
| LABELS: ${{ join(github.event.pull_request.labels.*.name, ', ') }} | |
| REPO: ${{ github.event.pull_request.head.repo.full_name }} | |
| CREATOR: ${{ github.event.pull_request.user.login }} | |
| STATE: ${{ github.event.pull_request.state }} | |
| ASSIGNEES: ${{ join(github.event.pull_request.assignees.*.login, ', ') }} | |
| REVIEWERS: ${{ join(github.event.pull_request.requested_reviewers.*.login, ', ') }} | |
| URL: ${{ github.event.pull_request.html_url }} | |
| run: | | |
| if [ -z "$WEBHOOK_URL" ]; then | |
| echo "WEBHOOK_URL secret is not set (e.g. fork PR). Skipping notification." | |
| exit 0 | |
| fi | |
| PAYLOAD=$(jq -n \ | |
| --arg pr_num "$PR_NUMBER" \ | |
| --arg title "$TITLE" \ | |
| --arg labels "$LABELS" \ | |
| --arg repo "$REPO" \ | |
| --arg creator "$CREATOR" \ | |
| --arg state "$STATE" \ | |
| --arg assignees "$ASSIGNEES" \ | |
| --arg reviewers "$REVIEWERS" \ | |
| --arg url "$URL" \ | |
| ' | |
| def guard(val): if (val == null or val == "") then "None" else val end; | |
| def guard_list(val): if (val == null or val == "") then "None" else "- " + val end; | |
| { | |
| cardsV2: [ | |
| { | |
| cardId: "prNotificationCard", | |
| card: { | |
| header: { | |
| title: "Pull request notification", | |
| subtitle: ("Pull request: #" + guard($pr_num)) | |
| }, | |
| sections: [ | |
| { | |
| widgets: [ | |
| { decoratedText: { topLabel: "Repo", text: guard($repo) } }, | |
| { decoratedText: { topLabel: "Title", text: guard($title) } }, | |
| { decoratedText: { topLabel: "Creator", text: guard($creator) } }, | |
| { decoratedText: { topLabel: "State", text: guard($state) } }, | |
| { decoratedText: { topLabel: "Assignees", text: guard_list($assignees) } }, | |
| { decoratedText: { topLabel: "Reviewers", text: guard_list($reviewers) } }, | |
| { decoratedText: { topLabel: "Labels", text: guard_list($labels) } }, | |
| { | |
| buttonList: { | |
| buttons: [ | |
| { | |
| text: "Open Pull Request", | |
| onClick: { | |
| openLink: { | |
| url: $url | |
| } | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| }') | |
| RESPONSE=$(curl --fail-with-body --location --request POST "$WEBHOOK_URL" \ | |
| --header 'Content-Type: application/json; charset=UTF-8' \ | |
| --data-raw "$PAYLOAD" 2>&1) || { | |
| echo "Failed to send Google Chat notification:" | |
| echo "$RESPONSE" | |
| exit 1 | |
| } | |