Repository navigation
Update push and pr notification to use Cards v2. #488
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 | |
| 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: | | |
| 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" \ | |
| '{ | |
| cardsV2: [ | |
| { | |
| cardId: "prNotificationCard", | |
| card: { | |
| header: { | |
| title: "Pull request notification", | |
| subtitle: ("Pull request: #" + $pr_num) | |
| }, | |
| sections: [ | |
| { | |
| widgets: [ | |
| { | |
| decoratedText: { | |
| topLabel: "Repo", | |
| text: $repo | |
| } | |
| }, | |
| { | |
| decoratedText: { | |
| topLabel: "Title", | |
| text: $title | |
| } | |
| }, | |
| { | |
| decoratedText: { | |
| topLabel: "Creator", | |
| text: $creator | |
| } | |
| }, | |
| { | |
| decoratedText: { | |
| topLabel: "State", | |
| text: $state | |
| } | |
| }, | |
| { | |
| decoratedText: { | |
| topLabel: "Assignees", | |
| text: (if $assignees != "" then "- " + $assignees else "None" end) | |
| } | |
| }, | |
| { | |
| decoratedText: { | |
| topLabel: "Reviewers", | |
| text: (if $reviewers != "" then "- " + $reviewers else "None" end) | |
| } | |
| }, | |
| { | |
| decoratedText: { | |
| topLabel: "Labels", | |
| text: (if $labels != "" then "- " + $labels else "None" end) | |
| } | |
| }, | |
| { | |
| buttonList: { | |
| buttons: [ | |
| { | |
| text: "Open Pull Request", | |
| onClick: { | |
| openLink: { | |
| url: $url | |
| } | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| }') | |
| curl --location --request POST "$WEBHOOK_URL" \ | |
| --header 'Content-Type: application/json; charset=UTF-8' \ | |
| --data "$PAYLOAD" | |