diff --git a/README.md b/README.md index 9365559..e49201b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

Github Telegram Notify

+

GitHub Telegram Notify

Actions that sends commit updates of a repository to any chat in Telegram

🏪 View on Github Marketplace 🏷️ v1.1.2

@@ -20,16 +20,56 @@ A Telegram Bot Token is required for using the Telegram bot from which the commi ### - `topic_id` (optional) Use this only if you have topics enabled. -## How to use +## How to use? + +### Basic example Add the following lines of code in your YML file. -```sh +```yml - name: Notify the commit on Telegram uses: EverythingSuckz/github-telegram-notify@main with: - bot_token: '${{ secrets.BOT_TOKEN }}' - chat_id: '${{ secrets.CHAT_ID }}' + bot_token: '${{ secrets.TELEGRAM_BOT_TOKEN }}' + chat_id: '${{ secrets.TELEGRAM_CHAT_ID }}' +``` + +### Advanced example + +You can also replace the content of your YML file with the following lines of code. + + +```yml +name: Telegram Notification +on: + push: + fork: + watch: + issues: + types: [created, closed, opended, reopened, locked, unlocked] + issue_comment: + types: [created, deleted] + pull_request: + types: [created, closed, opened, reopened, locked, unlocked, synchronize] + pull_request_target: + types: [created, closed, opened, reopened, locked, unlocked, synchronize] + pull_request_review_comment: + types: [created, deleted] + release: + types: [published, released] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Notify everything on Telegram + uses: EverythingSuckz/github-telegram-notify@main + with: + bot_token: '${{ secrets.TELEGRAM_BOT_TOKEN }}' + chat_id: '${{ secrets.TELEGRAM_CHAT_ID }}' + topic_id: '${{ secrets.TELEGRAM_TOPIC_ID }}' ``` ## Supported events diff --git a/types/base.go b/types/base.go index 2b53928..b4382bd 100644 --- a/types/base.go +++ b/types/base.go @@ -23,6 +23,8 @@ func (e *Metadata) ParseEvent() (event_type interface{}, err error) { event_type = &IssuesEvent{} case "pull_request": event_type = &PullRequestEvent{} + case "pull_request_target": + event_type = &PullRequestEvent{} case "pull_request_review_comment": event_type = &PullRequestReviewCommentEvent{} case "push": diff --git a/utils/parser.go b/utils/parser.go index 02daaba..ba529bd 100644 --- a/utils/parser.go +++ b/utils/parser.go @@ -52,6 +52,19 @@ func CreateContents(meta *types.Metadata) (text string, markupText string, marku return } + text = createPullRequestText(event) + markupText = "Open Pull Request" + markupUrl = event.PullRequest.HTMLURL + case "pull_request_target": + event := event.(*types.PullRequestEvent) + + if !Contains([]string{ + "created", "opened", "reopened", "locked", "unlocked", "closed", "synchronize", // More to be added. + }, event.Action) { + err = fmt.Errorf("unsupported event type '%s' for %s", event.Action, meta.EventName) + return + } + text = createPullRequestText(event) markupText = "Open Pull Request" markupUrl = event.PullRequest.HTMLURL