|
| 1 | +# Workflows |
| 2 | + |
| 3 | +Compass uses GitHub Actions for continuous integration, Docker Hub for image distribution, and a VPS for staging. |
| 4 | + |
| 5 | +| Workflow | Trigger | Purpose | |
| 6 | +|---|---|---| |
| 7 | +| Test | Push / PR to `main` | Runs lint, type-check, and unit tests | |
| 8 | +| CodeQL | Push / PR to `main` | Static security analysis | |
| 9 | +| Bump version and tag | Push to `main` | Auto-increments patch version, pushes a new semver tag | |
| 10 | +| Publish Docker images | Push a `v*.*.*` tag | Builds images, pushes to Docker Hub, deploys to staging | |
| 11 | +| Sync docs to compass-docs | Push to `main` touching `docs/**` | Mirrors this `docs/` directory to docs.compasscalendar.com | |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Release Flow |
| 16 | + |
| 17 | +Every PR merge to `main` triggers a fully automated chain: |
| 18 | + |
| 19 | +``` |
| 20 | +PR merged to main |
| 21 | + └─► bump-and-tag.yml — reads latest tag, pushes v1.2.X+1 |
| 22 | + └─► publish-images.yml — builds & pushes images to Docker Hub |
| 23 | + └─► deploy-staging — SSHes into VPS, runs ./compass update |
| 24 | +``` |
| 25 | + |
| 26 | +**Monthly minor/major releases** remain manual: a maintainer pushes a tag like `v1.3.0` or `v2.0.0`, which skips the bump step and goes straight to publish + deploy. |
| 27 | + |
| 28 | +### Removing a test tag |
| 29 | + |
| 30 | +```sh |
| 31 | +git push origin --delete v1.2.3 |
| 32 | +git tag -d v1.2.3 |
| 33 | +``` |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Publish Docker Images |
| 38 | + |
| 39 | +Source: [`.github/workflows/publish-images.yml`](../../.github/workflows/publish-images.yml) |
| 40 | + |
| 41 | +### How it works |
| 42 | + |
| 43 | +1. A semver tag matching `v[0-9]+.[0-9]+.[0-9]+` is pushed (either by `bump-and-tag.yml` or manually). |
| 44 | +2. The workflow strips the `v` prefix and derives two tag aliases: |
| 45 | + - `1.2.3` — exact patch version |
| 46 | + - `1.2` — floating minor alias |
| 47 | +3. It builds and pushes three images to [our Docker Hub](https://hub.docker.com/repositories/switchbacktech): |
| 48 | + - `switchbacktech/compass-backend` |
| 49 | + - `switchbacktech/compass-mongo` |
| 50 | + - `switchbacktech/compass-web` |
| 51 | +4. Each image gets all three tags: `1.2.3`, `1.2`, and `latest`. |
| 52 | +5. After all images are pushed, the `deploy-staging` job runs. |
| 53 | + |
| 54 | +### Tag pattern rules |
| 55 | + |
| 56 | +Only clean semver tags trigger the workflow. Tags with suffixes (e.g. `v1.2.3-test`) do not match and are safe to push for local testing without triggering a deploy. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Staging Deploy |
| 61 | + |
| 62 | +Source: `deploy-staging` job in [`.github/workflows/publish-images.yml`](../../.github/workflows/publish-images.yml) |
| 63 | + |
| 64 | +The deploy job SSHes into the staging VPS and runs `./compass update`, which pulls the latest Docker Hub images and restarts the stack. |
| 65 | + |
| 66 | +### Required secrets |
| 67 | + |
| 68 | +All secrets go in **GitHub → Settings → Secrets and variables → Actions**: |
| 69 | + |
| 70 | +| Secret | Value | |
| 71 | +|---|---| |
| 72 | +| `DOCKERHUB_USERNAME` | Docker Hub username for the `switchbacktech` org | |
| 73 | +| `DOCKERHUB_TOKEN` | Docker Hub personal access token (Read & Write) | |
| 74 | +| `STAGING_SSH_HOST` | VPS IP address or hostname | |
| 75 | +| `STAGING_SSH_USER` | Linux user on the VPS that owns `~/compass` | |
| 76 | +| `STAGING_SSH_KEY` | Private key from the deploy keypair (the `compass-staging-deploy` file, not `.pub`) | |
0 commit comments