# notification-action **Repository Path**: ouuan/notification-action ## Basic Information - **Project Name**: notification-action - **Description**: 将 GitHub webhook event 转化为通知消息的 GitHub Action - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-05-03 - **Last Updated**: 2023-02-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Notification Messages GitHub Actions for generating notification messages for various GitHub webhook events :bell: [![Codacy Badge](https://api.codacy.com/project/badge/Grade/657169ad6bcc4e449e4a66efad58d630)](https://www.codacy.com/manual/ouuan/notification-action?utm_source=github.com&utm_medium=referral&utm_content=ouuan/notification-action&utm_campaign=Badge_Grade) [![GitHub Actions Status](https://github.com/ouuan/notification-action/workflows/CI%20Test/badge.svg)](https://github.com/ouuan/notification-action/actions?query=workflow%3A"CI+Test") ## Get Started Create `.github/workflows/notification.yml` with the following content: ```yaml name: Notification on: [push] jobs: notification: runs-on: ubuntu-latest steps: - name: "Get the message" uses: ouuan/notification-action@master id: get-message with: format: markdown - name: "Output the message" run: echo '${{ steps.get-message.outputs.message }}' ``` ## Demo ### Plain Text ```plaintext ouuan forced-pushed 1 commit to notification-action:master: 49b264e - feat: Add format option by. ouuan ``` ### Markdown > ouuan pushed [2 commits](https://github.com/ouuan/notification-action/compare/49b264ec0ff0...fdf637251330) to [notification-action](https://github.com/ouuan/notification-action):[master](https://github.com/ouuan/notification-action/tree/master): > > [f7e4c1c](https://github.com/ouuan/notification-action/commit/f7e4c1cdb2b2a92277f25fab8bcc827e466aa89a) - refactor: Fix Codacy issue by. ouuan > [fdf6372](https://github.com/ouuan/notification-action/commit/fdf6372513306d995930ea62eaf151564f8103b4) - refactor: Change the order of inputs by. ouuan ### Tests You can see more examples in the [tests](tests) folder. ## Inputs **Tips**: You don't have to manually set `event-name` and `event-json`, just use the default values. | Name | Description | Default | | :--------: | :----------------------------------------------------------: | :---------------------------: | | format | The output format. Possible values: "markdown", "plaintext". | `plaintext` | | event-name | The name of the webhook event. | `${{ github.event_name }}` | | event-json | The webhook event converted to JSON. | `${{ toJSON(github.event) }}` | ## Outputs **Tips**: You can use `steps..outputs.message` to get the output. See [GitHub Help](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#steps-context) for more information. | Name | Description | | :-----: | :-----------------------: | | message | The notification message. | ## Supported webhook events | Name | PlainText | Markdown | | :------------------------------------------------------------------------------------------------: | :-------: | :------: | | [push](https://help.github.com/en/actions/reference/events-that-trigger-workflows#push-event-push) | √ | √ | ## Example usage You can use this with other GitHub Actions like [appleboy/telegram-action](https://github.com/appleboy/telegram-action): ```yaml name: telegram message on: [push] jobs: notification: runs-on: ubuntu-latest steps: - name: "Get the message" uses: ouuan/notification-action@master id: get-message - name: "Send the message" uses: appleboy/telegram-action@master with: to: ${{ secrets.TELEGRAM_TO }} token: ${{ secrets.TELEGRAM_TOKEN }} args: ${{ steps.get-message.outputs.message }} ``` ## Contrubuting - Improve the document. - Add ideas for new messages / better messages in [Issues](https://github.com/ouuan/notification-action/issues). - Add messages for more events and more formats and improve the current messages. Usually you need to modify: 1. `webhook2message/xxx.py` 2. [`__init__.py`](webhook2message/__init__.py) 3. `tests/xxx.json` You can refer to [Event Types & Payloads | GitHub Developer Guide](https://developer.github.com/v3/activity/events/types/), the [tests](tests) and the outputs in the GitHub Actions runs.