To send a text from a GitHub Actions workflow or a cron job, run curl against your SMS provider's REST API with the key held as a secret. It takes one step and no extra service. The hard part isn't the request. It's deciding which events deserve a text so people don't start ignoring them.
We make Ready, so the examples use the Ready REST API and only the request shape we document. Everything here is plain shell and YAML.
Texting your own team: what's fine
An on-call text to staff who agreed to receive it is operational messaging between a company and its own people. Get a clear yes from each person, keep the list short, and let anyone reply STOP. On Ready, an inbound STOP is honored automatically and later sends to that number are refused, so build your alert script to expect a refused send for someone who left the rotation. The internal texting guide covers the consent side.
A GitHub Actions step
Store the key as a repository or environment secret named READY_API_KEY, and the recipient as ONCALL_PHONE. Then add a step that only runs when something failed:
name: deploy
on:
push:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./deploy.sh
- name: Text on failure
if: failure()
env:
READY_API_KEY: ${{ secrets.READY_API_KEY }}
ONCALL_PHONE: ${{ secrets.ONCALL_PHONE }}
run: |
curl -sS --fail-with-body --retry 3 -X POST https://api.tryready.com/v1/messages \
-H "X-API-Key: $READY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: deploy-${{ github.run_id }}-${{ github.run_attempt }}" \
-d "{\"to\": \"$ONCALL_PHONE\", \"body\": \"Deploy failed on ${{ github.ref_name }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\", \"consent_attested\": true}" The idempotency key uses the run ID and attempt number, so a re-run of the same attempt can't double-text, and a genuine re-run after a fix still can. Secrets are masked in logs, but don't echo them yourself. For pull requests from forks, GitHub doesn't pass secrets at all, which is the behavior you want.
One caution: put only values you trust inside the JSON string. A branch name with a quote in it could break the payload. If that's a risk, build the JSON with jq and its argument option instead of string interpolation.
A cron job
For a nightly job on a server, make the text part of the failure path:
#!/usr/bin/env bash
set -u
if ! /usr/local/bin/nightly-backup.sh; then
curl -sS --fail-with-body --retry 3 -X POST https://api.tryready.com/v1/messages \
-H "X-API-Key: $READY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: backup-$(date +%F)" \
-d '{"to": "+12125550199", "body": "Nightly backup failed on db-01.", "consent_attested": true}' \
|| logger -t backup-alert "SMS alert failed"
fi The date-based key means even if cron fires the wrapper twice by mistake, one text goes out per day. Load READY_API_KEY from a file readable only by the cron user, not from the crontab itself, since crontabs are easy to leak.
Decide what deserves a text
A text interrupts someone, so reserve it for events that need a human now:
| Event | Text? | Better channel |
|---|---|---|
| Production deploy failed | Yes | Chat as well |
| Nightly backup failed | Yes | Ticket |
| Test suite red on a branch | No | Chat or email |
| Certificate expires in 3 days | Yes, once | Ticket |
| Dependency update available | No | Email digest |
If every failure texts, people mute the number within a week. Send once per incident, not once per retry. The critical alert fallback ladder shows how to step up from chat to text to a call.
Handling failures of the alert itself
An alert that fails silently is worse than none. Check the HTTP status (curl -f makes curl exit non-zero on 4xx and 5xx) and make the step or script log loudly. For flaky networks, turn on curl's retry option; because the idempotency key is stable, retries after a timeout or a 429 are safe. A 503 was not sent, but the same key replays that stored answer, so resend it under a new key such as backup-$(date +%F)-2. The exact error bodies are in the error reference, and our monitoring post covers watching the sender itself.
Cost
A short alert is one segment: $0.0075 plus a $0.0045 carrier fee, excluding optional screening. Fifty alerts a month is 50 × ($0.0075 + $0.0045), well under the cost of one missed outage. A card on file and a number of your own ($2 a month) are required to send. See pricing.
Ready's all-in prices per segment include the carrier fee but not screening: Scrub lists and Number validation, the two switches in Settings under Compliance, each add $0.003 per segment when switched on, shown as screening on your bill, and both are off by default. Unless you turn the opt-out footer off, the first text to each contact, and one again from time to time, also gets "Reply STOP to opt out" and your business name if the message does not already have them, so a text close to the segment limit can bill one more segment.
FAQ
Is it safe to put the API key in GitHub Actions secrets?
Yes, that's what secrets are for. Use environment-level secrets with required reviewers for production keys, and don't print them. Rotate the key if a workflow file is ever changed by someone you don't trust.
Can I text from a workflow triggered by a pull request?
On the pull_request event from a fork, secrets aren't available, so the step can't send. For same-repo branches it works. Avoid pull_request_target unless you understand its risks.
Why not just use email or Slack for alerts?
Use them first. Text is the escalation for the few events where nobody will see a chat message in time.
The short version
One curl step, a secret, a stable idempotency key and a strict list of events. Our curl guide covers the request in more detail.