Skip to content

Commit f4c1df2

Browse files
Refactor CI/CD: split CI from CD, tag-only deploys, manual redeploy gate
- test job runs on all push events (branch + tag); publish/deploy only on v* tags - deploy uses semver version tag instead of SHA for traceability - add workflow_dispatch to redeploy a specific existing version - remove latest and SHA Docker tags; add major.minor floating tag - update CLAUDE.md and release.md to reflect new workflow
1 parent eebe163 commit f4c1df2

3 files changed

Lines changed: 36 additions & 7 deletions

File tree

.claude/CLAUDE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ git config core.hooksPath .githooks
2626
```
2727

2828
## CI/CD
29-
Push to `main` → GitHub Actions runs Rust tests + admin-ui tests → builds Docker image → deploys to Fly.io.
29+
- Push to `main` → tests only (Rust + admin-ui)
30+
- Push `v*` tag → tests → build & publish Docker image (tagged `X.Y.Z` + `X.Y`) → deploy to Fly.io
31+
- `workflow_dispatch` in GitHub Actions → redeploy a specific existing version
32+
33+
Use `/release` to prepare the changelog, bump versions, commit, and tag. Use `/commit` for day-to-day commits.
3034

3135
## Migrations (`migration/`)
3236

.claude/commands/release.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,7 @@ Tell the user the release is ready and show the exact command to push:
4949
git push && git push origin vX.Y.Z
5050
```
5151

52-
Remind them that pushing the tag triggers CI to build and publish a Docker image tagged `vX.Y.Z`.
52+
Remind them that:
53+
- Pushing the commit (`git push`) triggers CI: tests only.
54+
- Pushing the tag (`git push origin vX.Y.Z`) triggers CI: tests → build → publish Docker image tagged `X.Y.Z` and `X.Y` → deploy to Fly.io.
55+
- To redeploy an existing version without a new release, use the `workflow_dispatch` trigger in GitHub Actions with the version number (e.g. `1.2.3`).

.github/workflows/cicd.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
name: Publish & Deploy
1+
name: CI / CD
22

33
on:
44
push:
55
branches: [main]
66
tags: ['v*']
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to deploy (e.g. 1.2.3 — must already exist in GHCR)'
11+
required: true
712

813
jobs:
914
test:
15+
if: github.event_name == 'push'
1016
runs-on: ubuntu-latest
1117
steps:
1218
- uses: actions/checkout@v4
@@ -40,10 +46,13 @@ jobs:
4046

4147
publish:
4248
needs: test
49+
if: startsWith(github.ref, 'refs/tags/v')
4350
runs-on: ubuntu-latest
4451
permissions:
4552
contents: read
4653
packages: write
54+
outputs:
55+
version: ${{ steps.meta.outputs.version }}
4756
steps:
4857
- uses: actions/checkout@v4
4958

@@ -63,9 +72,8 @@ jobs:
6372
with:
6473
images: ghcr.io/getbetweenrows/betweenrows
6574
tags: |
66-
type=raw,value=latest,enable={{is_default_branch}}
6775
type=semver,pattern={{version}}
68-
type=sha,prefix=,format=long
76+
type=semver,pattern={{major}}.{{minor}}
6977
7078
- name: Build and push
7179
uses: docker/build-push-action@v6
@@ -79,15 +87,29 @@ jobs:
7987
cache-to: type=gha,mode=max
8088

8189
deploy:
82-
needs: publish
90+
needs: [publish]
91+
if: |
92+
always() && (
93+
(needs.publish.result == 'success') ||
94+
(github.event_name == 'workflow_dispatch')
95+
)
8396
runs-on: ubuntu-latest
8497
timeout-minutes: 5
8598
steps:
8699
- uses: actions/checkout@v4
87100

101+
- name: Resolve version
102+
id: version
103+
run: |
104+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
105+
echo "tag=${{ inputs.version }}" >> $GITHUB_OUTPUT
106+
else
107+
echo "tag=${{ needs.publish.outputs.version }}" >> $GITHUB_OUTPUT
108+
fi
109+
88110
- name: Deploy to Fly.io
89111
uses: superfly/flyctl-actions/setup-flyctl@master
90112

91-
- run: flyctl deploy --image ghcr.io/getbetweenrows/betweenrows:${{ github.sha }} --app betweenrows
113+
- run: flyctl deploy --image ghcr.io/getbetweenrows/betweenrows:${{ steps.version.outputs.tag }} --app betweenrows
92114
env:
93115
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

0 commit comments

Comments
 (0)