Skip to content

Commit

Permalink
🔧 trying akeylimepie/telegram-action@main
Browse files Browse the repository at this point in the history
  • Loading branch information
vokimon committed Nov 27, 2024
1 parent 543d1bd commit a5ae509
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
42 changes: 28 additions & 14 deletions .github/actions/notify-team/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,51 @@ runs:
echo "RUN_ID=${{github.run_id}}"
echo "REPORT_GREEN_TO_GREEN=${{inputs.ignore_green_to_green == false}}"
function status_icon() {
([ "$1" == "failure" ] && echo '❌') ||
([ "$1" == "success" ] && echo '✅') ||
([ "$1" == "new_branch" ] && echo '✨' ) ||
echo "$1"
case "$1" in
"failure" ) echo '❌';;
"success" ) echo '✅';;
"new_branch") echo '✨';;
"queued") echo '⏳';;
"in_progress") echo '⚙';;
"cancelled") echo '🚫';;
"skipped") echo '⏭️';;
"timed_out") echo '👴';;
*) echo "$1";;
esac
}
LAST_RUN_ICON="$( status_icon $LAST_RUN)"
THIS_RUN_ICON="$( status_icon ${{ job.status }} )"
echo LAST_RUN_ICON="$LAST_RUN_ICON" >> $GITHUB_ENV
echo THIS_RUN_ICON="$THIS_RUN_ICON" >> $GITHUB_ENV
echo "$LAST_RUN_ICON -> $THIS_RUN_ICON"
echo THIS_RUN_LINK="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
echo REPO_NAME="${{github.event.repository.name}}" >> $GITHUB_ENV
echo REPO_LINK="https://github.com/${{ github.repository }})" >> $GITHUB_ENV
echo CHANGES_LINK="https://github.com/${{ github.repository }}/commit/${{ github.sha }}" >> $GITHUB_ENV
echo COMMIT_MESSAGE="${{github.event.head_commit.message}}" >> $GITHUB_ENV
echo AVATAR_URL="${{ format('https://github.com/{0}.png', github.event.head_commit.author.username) }}" >> $GITHUB_ENV
echo AUTHOR_NAME="${{ github.event.head_commit.author.username }}" >> $GITHUB_ENV
echo BRANCH="${{ github.ref_name }} >> $GITHUB_ENV
- name: 📢 Notify changes in Telegram
uses: cbrgm/telegram-github-action@v1
uses: akeylimepie/telegram-action@main
if: job.status != 'success' || env.LAST_RUN != 'success' || inputs.ignore_green_to_green == false

# this allows the build to succeed even when the notification fails
# e.g. due to dependabot push, which may not have the secret
continue-on-error: true
with:
token: ${{ inputs.token }}
to: ${{ inputs.to }}
parse-mode: 'markdown'
disable-web-page-preview: true
message: |
${{ format('{3} → {2}: {0} `[{1}]`', github.event.repository.name, github.ref_name, env.THIS_RUN_ICON, env.LAST_RUN_ICON) }}
chat_id: ${{ inputs.to }}
parse_mode: html
#disable-web-page-preview: true
text: |
<b>${{ format('{0} → {1}: {2} `[{3}]`', env.LAST_RUN_ICON, env.THIS_RUN_ICON, env.REPO_NAME, env.BRANCH) }}</b>
${{ format('Author: {0} ![Avatar](https://github.com/{1}.png)', github.event.head_commit.author.name, github.event.head_commit.author.username ) }}
${{ format('<b>Author:</b> {0} <img src="{1}"/>', env.AUTHOR_NAME, env.AVATAR_URL ) }}
Commit: ${{ github.event.head_commit.message }}
<blockquote>${{ env.COMMIT_MESSAGE }}</blockquote>
[Details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - [Repository](https://github.com/${{ github.repository }}) - [Changes](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
<a href="${{ env.THIS_RUN_LINK }}">Details</a> · <a href="${{ env.REPO_LINK }}">Repository</a> · <a href="${{ env.CHANGES_LINK }}">Changes</a>
# - name: Google Chat Notificationa
# uses: SimonScholz/google-chat-action@main
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
with:
token: ${{ secrets.TELEGRAM_TOKEN }}
to: ${{ secrets.TELEGRAM_CHAT_ID }}
report_green_to_green: true

coveralls_finish:
needs: build
Expand Down

0 comments on commit a5ae509

Please sign in to comment.