diff --git a/README.md b/README.md index 107752f..8ff43b2 100644 --- a/README.md +++ b/README.md @@ -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/google-chat-notifications@v3.0.0 with: title: Build + subtitle: ${{ github.event.head_commit.message }} webhookUrl: ${{ secrets.GOOGLE_CHAT_WEBHOOK }} status: ${{ job.status }} threadKey: ${{ secrets.GOOGLE_CHAT_THREAD_KEY }} diff --git a/dist/index.js b/dist/index.js index 3ab2d19..bf7df18 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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}`); } @@ -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 })); diff --git a/src/chat.ts b/src/chat.ts index 14aeee7..b1b0bcc 100644 --- a/src/chat.ts +++ b/src/chat.ts @@ -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}`) } diff --git a/src/main.ts b/src/main.ts index 324dbaa..84f196f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 }))