Send a metric from GitHub Actions with one curl step
Count deploys, count failures, and chart how long each deploy took — with two curl calls in one step and your key in a repository secret. No marketplace action to trust, no collector to run, and a chart per stat the moment the first point lands.
Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Paid plans are $19, $49 or $99 a month, and every paid plan tracks 10,000 stats. Prices are flat and monthly, in USD, + tax where applicable. /pricing is the source of truth.
Before you start
Create an account, copy your API key, and add it to the repository as a secret named EZSTAT_API_KEY. The key works at once, with one stat and 500 datapoints a day until you confirm your email address; confirm within 7 days to keep sending. The workflow below writes more than one stat, so confirm before you run it.
The workflow
name: deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start timer
run: echo "STARTED_AT=$(date +%s)" >> "$GITHUB_ENV"
- name: Deploy
run: ./scripts/deploy.sh
- name: Record deploy metrics
if: always() # also runs when the deploy failed
env:
EZSTAT_API_KEY: ${{ secrets.EZSTAT_API_KEY }}
JOB_STATUS: ${{ job.status }} # success | failure | cancelled
run: |
api="https://api.ezstat.dev/api/v1/stats"
seconds=$(( $(date +%s) - STARTED_AT ))
curl -fsS -m 10 -X POST "$api/deploys_${JOB_STATUS}/count" \
-H "Authorization: Bearer $EZSTAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"count": 1}' || echo "::warning::could not record deploy count"
curl -fsS -m 10 -X POST "$api/deploy_seconds/value" \
-H "Authorization: Bearer $EZSTAT_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"value\": $seconds}" || echo "::warning::could not record deploy duration"- → The timer is one line:
date +%sintoGITHUB_ENVbefore the deploy. - →
if: always()runs the step even when the deploy failed — otherwise a broken deploy is the one you never chart. - →
job.statusissuccess,failureorcancelled, so one counter per outcome.
Why a count per outcome
A stat is one kind — a counter or a gauge, never both — so successes, failures and cancellations are separate counters and the duration is a gauge. This workflow creates up to four stats; the free plan allows 10 stats.
Do not fail the workflow over a metric
Each call has a ten-second timeout and a || echo "::warning::…" fallback, so a metrics outage produces a warning annotation instead of a red build. The step reports; it never changes the deploy's own result.
Pull requests from forks
GitHub does not give repository secrets to workflows triggered by pull requests from forks, so the metric step would run without a key and every call would be rejected with 401. Run it on push to your main branch, as the example does.
What you see
A chart per stat: deploy counts by outcome, and deploy duration over time. Export to CSV or JSON any time. This is not a DORA dashboard and there are no per-job tags — a stat is a name, so put the dimension in the name if you need one. Alerts on paid plans, by webhook or Slack, checked periodically — not instant.
The same step elsewhere
The two calls are ordinary HTTPS, so the same step works in any CI system, in a cron wrapper (/cron-metrics), or from a script (Python, Node.js, Go). If you were about to add a full observability platform for this, read this first.
Price and limits
Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Ten stats cover two workflows at four stats each. Paid plans are $19, $49 or $99 a month with every paid plan tracks 10,000 stats; the history you can see and export is 30 days on Free and Indie, 1 year on Pro, 3 years on Scale. See the full table.
Questions
How do I send a custom metric from a GitHub Actions workflow?
Add a step that POSTs to EzStat with curl, with your key in a repository secret: curl -fsS -X POST https://api.ezstat.dev/api/v1/stats/deploys_success/count -H "Authorization: Bearer $EZSTAT_API_KEY" -H "Content-Type: application/json" -d '{"count": 1}'. Pass the secret in with env: EZSTAT_API_KEY: ${{ secrets.EZSTAT_API_KEY }}. EzStat creates the stat on the first request and draws a chart. There is no action to install.
How do I track deploy duration in GitHub Actions?
Save date +%s into GITHUB_ENV before the deploy, then in a final step with if: always() subtract it from the current time and POST the seconds as a value to a stat such as deploy_seconds. The step runs on failed deploys too, so you also see failures. EzStat charts the series, and the history you can see and export is 30 days on Free and Indie, 1 year on Pro, 3 years on Scale.
Will a failed metric call fail my GitHub Actions workflow?
Not if you handle it. Give curl a timeout with -m 10 and follow it with || echo "::warning::..." so a metrics outage produces a warning, not a red build. The metric step only reports; it does not change the deploy's own result.
Is it safe to put the EzStat key in a workflow?
Keep it in a repository secret and pass it through env:, never in the YAML. GitHub masks secrets in logs. Rotate the key if it ever appears in code.
Does this work for pull requests from forks?
No: GitHub does not pass repository secrets to workflows triggered by pull requests from forks, so the metric step would have no key. Run it on push to your main branch, as the example does.