GitHub Actions
Add one step to a workflow and a failed run, or a finished deploy, arrives on your devices with a button that opens the run on GitHub.
This uses an API Source, with curl and jq, which GitHub’s hosted
runners have. shell: bash makes the step run the same on Windows runners.
Set it up
Section titled “Set it up”-
In the Pocketbell app, create a Source named GitHub, choose API, and copy its key.
-
In the repository on GitHub, open Settings → Secrets and variables → Actions, click New repository secret, name it
POCKETBELL_KEY, paste the key, and click Add secret. -
Add this as the last step of the job you want to hear about:
- name: Tell Pocketbellif: failure()shell: bashenv:POCKETBELL_KEY: ${{ secrets.POCKETBELL_KEY }}WORKFLOW: ${{ github.workflow }}REPO: ${{ github.repository }}BRANCH: ${{ github.ref_name }}RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}run: |jq -n --arg title "$WORKFLOW failed" --arg message "$REPO on $BRANCH" --arg url "$RUN_URL" \'{title: $title, message: $message, priority: "important", tags: ["github"],url: $url, url_title: "Open run"}' |curl --fail-with-body -sS https://api.pocketbell.dev/v1/messages \-H "Authorization: Bearer $POCKETBELL_KEY" \-H "Content-Type: application/json" \--data @- -
Push, and the next failed run sends it.
Other moments
Section titled “Other moments”- Every run, pass or fail: change
if: failure()toif: always(), addSTATUS: ${{ job.status }}underenv:, and use"$WORKFLOW: $STATUS"as the title. - A deploy finished:
if: success()at the end of the deploy job, withpriority: "normal". - A failure that must wake you:
priority: "critical"repeats until you acknowledge it. See Critical notifications.
Why env: and jq
Section titled “Why env: and jq”Values such as a branch name, a pull request title or a commit message are
written by whoever pushed them. Passed through env:, they reach the script
as plain data and can’t run as commands, which is
GitHub’s own advice.
jq --arg turns each one into a JSON string, so quotes and line breaks in
them can’t break the request.
If nothing arrives
Section titled “If nothing arrives”The step’s log shows Pocketbell’s answer, since --fail-with-body prints it
and fails the step:
- 401
invalid_api_key: the secret is missing or wrong. Secrets aren’t passed to workflows run from forks. - 400
invalid_request:detailsin the answer names the field.