|
| 1 | +# Examples |
| 2 | + |
| 3 | +## Waiting for a deploy preview (action dependencies) |
| 4 | + |
| 5 | +A common setup is to run git-glimpse **after** another action deploys a preview |
| 6 | +(Cloudflare Pages, Vercel, Netlify, etc.). You don't need any special |
| 7 | +git-glimpse config for this — GitHub Actions already has the primitives. |
| 8 | + |
| 9 | +### How it works |
| 10 | + |
| 11 | +Use two jobs connected by `needs:`: |
| 12 | + |
| 13 | +```yaml |
| 14 | +jobs: |
| 15 | + deploy: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + preview-url: ${{ steps.deploy.outputs.url }} |
| 19 | + steps: |
| 20 | + - uses: cloudflare/pages-action@v1 # or vercel, netlify, etc. |
| 21 | + id: deploy |
| 22 | + with: ... |
| 23 | + |
| 24 | + glimpse: |
| 25 | + needs: deploy # ← waits for deploy to finish |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - uses: DeDuckProject/git-glimpse@v1 |
| 29 | + with: |
| 30 | + preview-url: ${{ needs.deploy.outputs.preview-url }} |
| 31 | +``` |
| 32 | +
|
| 33 | +`needs: deploy` tells GitHub to run the `glimpse` job only after `deploy` |
| 34 | +succeeds. The preview URL flows between jobs via `outputs`. |
| 35 | + |
| 36 | +### Handling propagation delay |
| 37 | + |
| 38 | +Even after the deploy action reports success, the preview URL may not be |
| 39 | +immediately reachable (DNS propagation, CDN warming, etc.). git-glimpse |
| 40 | +automatically polls the preview URL before recording, controlled by the |
| 41 | +`ready-timeout` input (default: 30 seconds): |
| 42 | + |
| 43 | +```yaml |
| 44 | +- uses: DeDuckProject/git-glimpse@v1 |
| 45 | + with: |
| 46 | + preview-url: ${{ needs.deploy.outputs.preview-url }} |
| 47 | + ready-timeout: '60' # wait up to 60s for the URL to respond |
| 48 | +``` |
| 49 | + |
| 50 | +### Supporting `/glimpse` comment triggers |
| 51 | + |
| 52 | +When a user comments `/glimpse` on a PR, the deploy job typically shouldn't |
| 53 | +re-run (the preview already exists from the original push). The example |
| 54 | +workflow handles this with conditional logic: |
| 55 | + |
| 56 | +- The deploy job only runs on `pull_request` events |
| 57 | +- The glimpse job uses `always()` so it still runs when deploy is skipped |
| 58 | +- On comment events, the preview URL falls back to a known value (e.g. a |
| 59 | + repository variable or the URL from the original deployment) |
| 60 | + |
| 61 | +### Full example |
| 62 | + |
| 63 | +See [`cloudflare-deploy/workflow.yml`](cloudflare-deploy/workflow.yml) for a |
| 64 | +complete, annotated workflow covering both PR pushes and `/glimpse` comment |
| 65 | +triggers with Cloudflare Pages. The same pattern applies to any deploy-preview |
| 66 | +service — just swap the deploy action and the output that carries the URL. |
| 67 | + |
| 68 | +## Simple local app |
| 69 | + |
| 70 | +See [`simple-app/`](simple-app/) for a minimal example that starts a local |
| 71 | +server and records against `localhost`. |
0 commit comments