|
| 1 | +# send-google-chat-webhook |
| 2 | + |
| 3 | +This github action will enable users to send notification to google chat via github actions. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | +### Obtain a web hook from your google chat workspace. |
| 7 | +1. Go to your chat space which you want to add a webhook. |
| 8 | +2. At the top, click on the space title, select Apps & Integration. |
| 9 | +3. Click Manage webhooks |
| 10 | +4. Create a webhook or add another webhook if there is already one. |
| 11 | +5. Copy the webhook URL that you intend to use for this github action. |
| 12 | + |
| 13 | +For your own security purposes, we would suggest to store your webhook url in github secrets, and use `${{ secrets.WEBHOOK_URL}}` to get it's value. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +```yaml |
| 18 | +jobs: |
| 19 | + job_id: |
| 20 | + # ... |
| 21 | + |
| 22 | + permissions: |
| 23 | + contents: 'read' |
| 24 | + id-token: 'write' |
| 25 | + |
| 26 | + steps: |
| 27 | + # ... |
| 28 | + |
| 29 | + - id: 'notify google chat' |
| 30 | + uses: 'google-github-actions/sent-google-chat-webhook@v0.0.1' |
| 31 | + with: |
| 32 | + webhook_url: '${{ secrets.WEBHOOK_URL }}' |
| 33 | + mention: "<users/all>" |
| 34 | +``` |
| 35 | +
|
| 36 | +You can customize the condition for when you want this action is called.. |
| 37 | +
|
| 38 | +```yaml |
| 39 | +- id: 'notify google chat' |
| 40 | + if: ${{ inputs.fail_intentionally }} |
| 41 | + uses: 'google-github-actions/sent-google-chat-webhook@v0.0.1' |
| 42 | + with: |
| 43 | + webhook_url: '${{ secrets.WEBHOOK_URL }}' |
| 44 | + mention: "<users/all>" |
| 45 | +``` |
| 46 | +
|
| 47 | +Helpful references: |
| 48 | +* Messages and Cards |
| 49 | + * [Create, read, update, delete messages](https://developers.google.com/chat/api/guides/crudl/messages) |
| 50 | + * [Send a card message](https://developers.google.com/chat/api/guides/message-formats/cards) |
| 51 | + * [REST Resource: spaces.messages](https://developers.google.com/chat/api/reference/rest/v1/spaces.messages) |
| 52 | + * [Method: spaces.messages.create](https://developers.google.com/chat/api/reference/rest/v1/spaces.messages/create) |
| 53 | + * [Cards v2](https://developers.google.com/chat/api/reference/rest/v1/cards) |
| 54 | +* abcxyz |
| 55 | + * [abcxyz/pkg/cli](https://pkg.go.dev/github.com/abcxyz/pkg/cli) |
0 commit comments