Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to telegram notifications #42

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ jobs:
-d parse_mode="Markdown"
}

send_telegram_message "Crave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has been queued %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has been queued %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
Expand Down Expand Up @@ -433,9 +433,9 @@ jobs:
make installclean && \
${{ github.event.inputs.BUILD_COMMAND }}"

# Send Build 'status' notification
# Send Build 'status' notification (Success)
- name: Telegram Notification
if: ${{ success() || cancelled() || failure() }}
if: ${{ success() }}
continue-on-error: true
run: |
send_telegram_message() {
Expand All @@ -447,14 +447,41 @@ jobs:
-d parse_mode="Markdown"
}

send_telegram_message "Crave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has status: $jobStatus %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
# Todo: error.log link
send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has Succeeded! %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}%0ADownload at: https://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/releases/tag/${{ github.run_id }}"

env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
jobStatus: ${{ job.status }}
skipSuccess: false

# Send Build 'status' notification (Fail/Cancel)
- name: Telegram Notification
if: ${{ cancelled() || failure() }}
continue-on-error: true
run: |
send_telegram_message() {
local message="$1"
curl -s -X POST \
https://api.telegram.org/bot$botToken/sendMessage \
-d chat_id=$chatId \
-d text="$message" \
-d parse_mode="Markdown"
}

if [ "$jobStatus" = "cancelled" ]; then
jobMessage="has been Cancelled!"
elif [ "$jobStatus" = "failure" ]; then
jobMessage="has Failed!"
fi

send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has status: $jobMessage %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
# Todo: error.log link
env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
jobStatus: ${{ job.status }}

# Only reach this wheter the user killed the workflow.
- name: Execute if the job is cancelled
if: ${{ cancelled() }}
Expand Down
37 changes: 32 additions & 5 deletions .github/workflows/selfhosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ jobs:
-d parse_mode="Markdown"
}

send_telegram_message "Crave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has been queued %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has been queued %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
Expand Down Expand Up @@ -459,9 +459,9 @@ jobs:
${{ github.event.inputs.BUILD_COMMAND }}"
timeout-minutes: 960

# Send Build 'status' notification
# Send Build 'status' notification (Success)
- name: Telegram Notification
if: ${{ success() || cancelled() || failure() }}
if: ${{ success() }}
continue-on-error: true
run: |
send_telegram_message() {
Expand All @@ -473,14 +473,41 @@ jobs:
-d parse_mode="Markdown"
}

send_telegram_message "Crave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has status: $jobStatus %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
# Todo: error.log link
send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has Succeeded! %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}%0ADownload at: https://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/releases/tag/${{ github.run_id }}"

env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
jobStatus: ${{ job.status }}
skipSuccess: false

# Send Build 'status' notification (Fail/Cancel)
- name: Telegram Notification
if: ${{ cancelled() || failure() }}
continue-on-error: true
run: |
send_telegram_message() {
local message="$1"
curl -s -X POST \
https://api.telegram.org/bot$botToken/sendMessage \
-d chat_id=$chatId \
-d text="$message" \
-d parse_mode="Markdown"
}

if [ "$jobStatus" = "cancelled" ]; then
jobMessage="has been Cancelled!"
elif [ "$jobStatus" = "failure" ]; then
jobMessage="has Failed!"
fi

send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has status: $jobMessage %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
# Todo: error.log link
env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
jobStatus: ${{ job.status }}

# Only reach this wheter the user killed the workflow.
- name: Execute if the job is cancelled
if: ${{ cancelled() }}
Expand Down
37 changes: 32 additions & 5 deletions .github/workflows/twrp-legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:
-d parse_mode="Markdown"
}

send_telegram_message "Crave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has been queued %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has been queued %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
Expand Down Expand Up @@ -357,9 +357,9 @@ jobs:
make installclean && \
${{ github.event.inputs.BUILD_COMMAND }}"

# Send Build 'status' notification
# Send Build 'status' notification (Success)
- name: Telegram Notification
if: ${{ success() || cancelled() || failure() }}
if: ${{ success() }}
continue-on-error: true
run: |
send_telegram_message() {
Expand All @@ -371,14 +371,41 @@ jobs:
-d parse_mode="Markdown"
}

send_telegram_message "Crave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has status: $jobStatus %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
# Todo: error.log link
send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has Succeeded! %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}%0ADownload at: https://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/releases/tag/${{ github.run_id }}"

env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
jobStatus: ${{ job.status }}
skipSuccess: false

# Send Build 'status' notification (Fail/Cancel)
- name: Telegram Notification
if: ${{ cancelled() || failure() }}
continue-on-error: true
run: |
send_telegram_message() {
local message="$1"
curl -s -X POST \
https://api.telegram.org/bot$botToken/sendMessage \
-d chat_id=$chatId \
-d text="$message" \
-d parse_mode="Markdown"
}

if [ "$jobStatus" = "cancelled" ]; then
jobMessage="has been Cancelled!"
elif [ "$jobStatus" = "failure" ]; then
jobMessage="has Failed!"
fi

send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has status: $jobMessage %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
# Todo: error.log link
env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
jobStatus: ${{ job.status }}

# Only reach this wheter the user killed the workflow.
- name: Execute if the job is cancelled
if: ${{ cancelled() }}
Expand Down
37 changes: 32 additions & 5 deletions .github/workflows/twrp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:
-d parse_mode="Markdown"
}

send_telegram_message "Crave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has been queued %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has been queued %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
Expand Down Expand Up @@ -357,9 +357,9 @@ jobs:
make installclean && \
${{ github.event.inputs.BUILD_COMMAND }}"

# Send Build 'status' notification
# Send Build 'status' notification (Success)
- name: Telegram Notification
if: ${{ success() || cancelled() || failure() }}
if: ${{ success() }}
continue-on-error: true
run: |
send_telegram_message() {
Expand All @@ -371,14 +371,41 @@ jobs:
-d parse_mode="Markdown"
}

send_telegram_message "Crave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has status: $jobStatus %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
# Todo: error.log link
send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has Succeeded! %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}%0ADownload at: https://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/releases/tag/${{ github.run_id }}"

env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
jobStatus: ${{ job.status }}
skipSuccess: false

# Send Build 'status' notification (Fail/Cancel)
- name: Telegram Notification
if: ${{ cancelled() || failure() }}
continue-on-error: true
run: |
send_telegram_message() {
local message="$1"
curl -s -X POST \
https://api.telegram.org/bot$botToken/sendMessage \
-d chat_id=$chatId \
-d text="$message" \
-d parse_mode="Markdown"
}

if [ "$jobStatus" = "cancelled" ]; then
jobMessage="has been Cancelled!"
elif [ "$jobStatus" = "failure" ]; then
jobMessage="has Failed!"
fi

send_telegram_message "Crave Project: ${{ github.event.inputs.BASE_PROJECT }}%0ACrave ProjectID: $PROJECTID %0ABuild for ${{ github.event.inputs.DEVICE_NAME }} has status: $jobMessage %0ACheck Progress at: %0Ahttps://github.com/$(echo "${{ github.repository }}" | sed 's@_@\\_@g')/actions/runs/${{ github.run_id }}"
# Todo: error.log link
env:
chatId: ${{ secrets.TELEGRAM_TO }}
botToken: ${{ secrets.TELEGRAM_TOKEN }}
jobStatus: ${{ job.status }}

# Only reach this wheter the user killed the workflow.
- name: Execute if the job is cancelled
if: ${{ cancelled() }}
Expand Down