File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+
15+ - uses : actions/setup-go@v5
16+ with :
17+ go-version : " 1.22"
18+
19+ - name : Run tests
20+ run : make test
21+
22+ deploy :
23+ runs-on : ubuntu-latest
24+ needs : test
25+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
26+ env :
27+ FLY_API_TOKEN : ${{ secrets.FLY_API_TOKEN }}
28+ steps :
29+ - name : Check for FLY_API_TOKEN
30+ id : check-token
31+ run : |
32+ if [ -n "$FLY_API_TOKEN" ]; then
33+ echo "has_token=true" >> $GITHUB_OUTPUT
34+ else
35+ echo "has_token=false" >> $GITHUB_OUTPUT
36+ echo "Skipping deploy - FLY_API_TOKEN not configured"
37+ fi
38+
39+ - uses : actions/checkout@v4
40+ if : steps.check-token.outputs.has_token == 'true'
41+
42+ - uses : superfly/flyctl-actions/setup-flyctl@master
43+ if : steps.check-token.outputs.has_token == 'true'
44+
45+ - name : Deploy to Fly.io
46+ if : steps.check-token.outputs.has_token == 'true'
47+ run : flyctl deploy --remote-only
Original file line number Diff line number Diff line change @@ -24,6 +24,15 @@ fly deploy
2424
2525The app will auto-stop when idle and auto-start on incoming requests to minimize costs.
2626
27+ ### CI/CD
28+
29+ Pushes to ` main ` automatically run tests and deploy to Fly.io via GitHub Actions.
30+
31+ To enable automatic deploys, add ` FLY_API_TOKEN ` to your repository secrets:
32+
33+ 1 . Generate a token: ` fly tokens create deploy -x 999999h `
34+ 2 . Add it to GitHub: Settings → Secrets and variables → Actions → New repository secret
35+
2736## Configuration
2837
2938### Environment Variables
You can’t perform that action at this time.
0 commit comments