Skip to content

Fly.io

Run Smoketest after Fly.io deploys from GitHub Actions or another CI pipeline.

View as Markdown

Fly.io deployments are commonly run from CI with flyctl. Add Smoketest as the next step after flyctl deploy succeeds.

Before you start

  1. Create a deployment webhook in Smoketest.
  2. Store the trigger URL as SMOKETEST_DEPLOYMENT_WEBHOOK_URL.
  3. Store your Fly.io token as FLY_API_TOKEN.

GitHub Actions

.github/workflows/fly-smoketest.yml
name: Deploy to Fly.io and run Smoketest

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: superfly/flyctl-actions/setup-flyctl@master
      - name: Deploy
        run: flyctl deploy --remote-only
        env:
          FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
      - name: Trigger Smoketest
        run: |
          curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
            -H "Idempotency-Key: ${{ github.run_id }}-${{ github.run_attempt }}" \
            --data-urlencode "targetUrl=$DEPLOYMENT_URL" \
            --data-urlencode "commitSha=${{ github.sha }}" \
            --data-urlencode "branch=${{ github.ref_name }}" \
            --data-urlencode "externalId=${{ github.run_id }}-${{ github.run_attempt }}"
        env:
          SMOKETEST_DEPLOYMENT_WEBHOOK_URL: ${{ secrets.SMOKETEST_DEPLOYMENT_WEBHOOK_URL }}
          DEPLOYMENT_URL: https://app.fly.dev

Review apps

For Fly.io review apps, set DEPLOYMENT_URL to the per-PR hostname created by your review-app workflow and include prNumber.

Shell
curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
  -H "Idempotency-Key: ${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" \
  --data-urlencode "targetUrl=${DEPLOYMENT_URL}" \
  --data-urlencode "commitSha=${GITHUB_SHA}" \
  --data-urlencode "branch=${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" \
  --data-urlencode "prNumber=${PR_NUMBER}" \
  --data-urlencode "externalId=${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"

On this page