How to get a notification on your phone when a backup or a long job finishes, or when a GitHub Actions run completes. All it takes is sending to a webhook URL with curl.
Create a URLWhen a job finishescronGitHub ActionsGood to know
The examples below keep the URL in the environment variable PUSHANY_URL.
export PUSHANY_URL=""
⚠️ Anyone who knows the URL can send to it. Don’t write it in your scripts; keep it in an environment variable or in GitHub Secrets.
Send text in the body with POST, and it arrives in your tray with a notification.
curl -d "Build finished" "$PUSHANY_URL"
Add it after a long command to be notified when it’s done. To send a different message for success and failure, write:
./backup.sh && curl -d "Backup completed" "$PUSHANY_URL" \
|| curl -d "Backup failed" "$PUSHANY_URL"
Send JSON to set a title and a message separately. Include a URL to open that page when you tap the notification.
curl -H "Content-Type: application/json" \
-d '{"title": "Server", "message": "Free disk space is below 10%", "url": "https://example.com/status"}' \
"$PUSHANY_URL"
Add it to the end of a cron job to know when it finished or failed.
0 3 * * * /home/me/backup.sh && curl -s -d "Nightly backup completed" ""
cron may not load the environment variables from your login shell. If so, read the URL from a file, for example.
PUSHANY_URL. - name: Notify my phone
if: always()
env:
PUSHANY_URL: ${{ secrets.PUSHANY_URL }}
run: >-
curl -sS
--data-urlencode "title=${{ github.workflow }}: ${{ job.status }}"
--data-urlencode "message=${{ github.repository }} (${{ github.ref_name }})"
--data-urlencode "url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
"$PUSHANY_URL"
To be notified only when a run fails, change if: always() to if: failure().
?archive=1 to the end of the URL. It’s saved to the archive instead of your tray list.?tags=CI to the end of the URL. When sending JSON, "tags": ["CI"] works too.