Send notifications all in one.
GitHub Action
# It won't work on `pull_request`, github won't pass secrets.xxx for the workflow triggered by pull request
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Notify telegram
# You could use master version, but it's recommended to use [latest release version](https://github.com/marketplace/actions/action-notify) instead.
uses: up9cloud/action-notify@master
if: cancelled() == false
env:
GITHUB_JOB_STATUS: ${{ job.status }}
TELEGRAM_BOT_TOKEN: ${{secrets.TELEGRAM_BOT_TOKEN}}
TELEGRAM_CHAT_ID: ${{secrets.TELEGRAM_CHAT_ID}}
# Or you could use this as standalone job:
notify:
if: cancelled() == false
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: up9cloud/action-notify@master
env:
GITHUB_JOB_STATUS: ${{ needs.deploy.result }}
TELEGRAM_BOT_TOKEN: ${{secrets.TELEGRAM_BOT_TOKEN}}
TELEGRAM_CHAT_ID: ${{secrets.TELEGRAM_CHAT_ID}}
# Custom template file path, relative to the repo root
TELEGRAM_TEMPLATE_PATH: "./test/telegram/custom.txt"
# Custom env, assign it from [GitHub context](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#contexts)
CUSTOM_VAR1: ${{github.repository_owner}}
CUSTOM_VAR2: "a custom variable"
See more usage examples: .github/workflows/main.yml
Drone CI
kind: pipeline
name: after
steps:
- name: notify
image: sstc/action-notify
environment:
CUSTOM_VAR2: "a custom variable in environment"
settings:
telegram_bot_token:
from_secret: telegram_bot_token
telegram_chat_id:
from_secret: telegram_chat_id
custom_var2: "a custom variable in settings"
Template will be parsed by envsubst, e.q.
Commit message: ${GIT_COMMIT_MESSAGE}
Repo owner: ${CUSTOM_VAR1}
Custom var: ${CUSTOM_VAR2}
Custom var in drone plugin settings: ${PLUGIN_CUSTOM_VAR2}
See more template examples: ./template/**/*
You can:
Common ones:
GITHUB_JOB_STATUS
: Required if you're using GitHub Action
, have to set this to let entrypoint.sh knows job status.
env:
GITHUB_JOB_STATUS: ${{ job.status }}
CUSTOM_SCRIPT
: Run custom script, and will ignore default action
VERBOSE
: show log or not, true or false
Platform related:
Telegram
TELEGRAM_TEMPLATE_PATH
: Telegram template file path
./template/telegram/${TEMPLATE}.${TELEGRAM_PARSE_MODE}
TELEGRAM_BOT_TOKEN
: Get it from @BotFather
TELEGRAM_CHAT_ID
: First sending messages to bot, then get it from https://api.telegram.org/bot<token>/getUpdates
TELEGRAM_PARSE_MODE
: txt
, md
or html
. This will map to telegram formatting options
txt
Slack
SLACK_TEMPLATE_PATH
: Slack template file path
./template/slack/${TEMPLATE}.json
SLACK_WEBHOOK_URL
: Get it from Incoming WebHooks
app
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
SLACK_API_TOKEN
: Slack api token, various. If you were using bot token, remember /invite @BOT_NAME
first
SLACK_CHANNEL
: Slack channel id
#general
Discord
DISCORD_TEMPLATE_PATH
: Discord template file path
./template/discord/${TEMPLATE}.json
DISCORD_WEBHOOK_URL
: Get it from Edit Channel -> Integrations -> Webhooks
Line
LINE_TEMPLATE_PATH
: Line.me template file path
./template/line.me/${TEMPLATE}.json
LINE_CHANNEL_ACCESS_TOKEN
: Get it from Developer console -> Bot -> Messaging api -> Channel access token (long-lived)
LINE_TO
: The user id, group id or chat id. Get it from webhook objects (have to build your server to receive objects)
Required if want to notify line.me
It can be multiple ids
user
s, if you want to notify mixed ids with group or chat id, you have
to trigger this action one by one.,
to separate each id, e.q.env:
LINE_TO: "Uxxxxxxxxxxx,Uxxxxxxxxxxx"
Template related
TEMPLATE
: Built in template style, see ./template/<vendor variants>/${TEMPLATE}.<ext>
debug
, default
or default.drone
GIT_SHA_SHORT
: Shorter commit sha cut -c1-8
GIT_COMMIT_MESSAGE
.commits[-1].message
, .workflow_run.head_commit.message
GIT_COMMIT_MESSAGE_ESCAPED
: Same as GIT_COMMIT_MESSAGE, but escaped, can be safely used in JSON template
{"msg":"${GIT_COMMIT_MESSAGE_ESCAPED}"}
GIT_COMMITTER_USERNAME
.commits[-1].committer.username
, .workflow_run.head_commit.committer.name
STATUS_COLOR
: The RGB color hex code based on job status and following settings:
STATUS_COLOR_SUCCESS
: The success color
#22863a
STATUS_COLOR_FAILURE
: The failure color
#cb2431
STATUS_COLOR_CANCELLED
: The cancelled color
#6a737d
STATUS_COLOR_DECIMAL
: The decimal code of STATUS_COLOR
STATUS_EMOJI
: The emoji based on job status and following settings:
STATUS_EMOJI_SUCCESS
: The success emoji
🟢
STATUS_EMOJI_FAILURE
: The failure emoji
🔴
STATUS_EMOJI_CANCELLED
: The cancelled emoji
⚪️