Skip to content

Commit

Permalink
Fix reply in thread
Browse files Browse the repository at this point in the history
Signed-off-by: ThinhHV <[email protected]>
  • Loading branch information
nakamuraos committed Mar 16, 2024
1 parent a6575a7 commit 4a83965
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# Google Chat Notification for GitHub Actions

![](https://github.com/nakamuraos/google-chat-notifications/workflows/Build/badge.svg)

Sends a Google Chat notification.

This repository is generated by [typescript-action](https://github.com/actions/typescript-action).

![Preview](images/preview.png "Preview")
![Preview](images/preview.png 'Preview')

## Usage

### Parameters
|Name|Required|Description|
|:---:|:---:|:---|
|title|true|Job title. Used for notification titles.|
|subtitle|false|Job subtitle. Used for notification subtitles. We recommend using `${{ github.event.head_commit.message }}`|
|webhookUrl|true|Google Chat Webhook URL.|
|status|true|Job status. Available values are `success`, `failure`, `cancelled`. We recommend using `${{ job.status }}`|
|threadKey|false|Thread key string. Used for send messages to a specific thread in a space|

| Name | Required | Default | Description |
| :--------: | :------: | :-----: | :---------------------------------------------------------------------------------------------------------- |
| title | | "Build" | Job title. Used for notification titles. |
| subtitle | | | Job subtitle. Used for notification subtitles. We recommend using `${{ github.event.head_commit.message }}` |
| webhookUrl || | Google Chat Webhook URL. |
| status || | Job status. Available values are `success`, `failure`, `cancelled`. We recommend using `${{ job.status }}` |
| threadKey | | | Thread key string. Used for send messages to a specific thread in a space |

### Examples

```yaml
- name: Google Chat Notification
uses: nakamuraos/[email protected]
with:
title: Build
subtitle: ${{ github.event.head_commit.message }}
webhookUrl: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
status: ${{ job.status }}
threadKey: ${{ secrets.GOOGLE_CHAT_THREAD_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32597,7 +32597,7 @@ function notify(_a) {
name: `spaces/${spacesKey}/threads/${threadKey}`,
};
}
const response = yield axios.default.post(webhookUrl, body);
const response = yield axios.default.post(webhookUrl + '&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD', body);
if (response.status !== 200) {
throw new Error(`Google Chat notification failed. response status=${response.status}`);
}
Expand Down Expand Up @@ -32652,7 +32652,7 @@ const GoogleChat = __importStar(__nccwpck_require__(5365));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const title = core.getInput('title', { required: true });
const title = core.getInput('title', { required: false }) || 'Build';
const subtitle = core.getInput('subtitle', { required: false });
const webhookUrl = core.getInput('webhookUrl', { required: true });
const status = JobStatus.parse(core.getInput('status', { required: true }));
Expand Down
5 changes: 4 additions & 1 deletion src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ export async function notify({
}
}

const response = await axios.default.post(webhookUrl, body)
const response = await axios.default.post(
webhookUrl + '&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD',
body,
)
if (response.status !== 200) {
throw new Error(`Google Chat notification failed. response status=${response.status}`)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as GoogleChat from './chat'

async function run() {
try {
const title = core.getInput('title', { required: true })
const title = core.getInput('title', { required: false }) || 'Build'
const subtitle = core.getInput('subtitle', { required: false })
const webhookUrl = core.getInput('webhookUrl', { required: true })
const status = JobStatus.parse(core.getInput('status', { required: true }))
Expand Down

0 comments on commit 4a83965

Please sign in to comment.