|
| 1 | +# Template CI Workflows |
| 2 | + |
| 3 | +This repository's GitHub Actions workflows are designed to be copied into template repositories. |
| 4 | + |
| 5 | +## What is included |
| 6 | + |
| 7 | +- Python reusable jobs (`.github/workflows/python-*.yml`) |
| 8 | +- Optional frontend reusable jobs for React/JavaScript (`.github/workflows/frontend-*.yml`) |
| 9 | +- Reusable Docker build/push job (`.github/workflows/build-and-push.yml`) |
| 10 | +- Main orchestrator (`.github/workflows/ci.yml`) with stack auto-detection and release support |
| 11 | + |
| 12 | +## Defaults and repo-level overrides |
| 13 | + |
| 14 | +`ci.yml` supports repository variables (`Settings -> Secrets and variables -> Actions -> Variables`) so you can reuse workflows without editing YAML in every repo. |
| 15 | + |
| 16 | +Set any of these optional variables: |
| 17 | + |
| 18 | +- `CI_PYTHON_VERSION` (default: `3.12`) |
| 19 | +- `CI_PYTHON_TEST_VERSIONS` (default: `["3.11","3.12","3.13"]`) |
| 20 | +- `CI_PYTHON_INSTALL_SPEC` (default: `.[dev]`) |
| 21 | +- `CI_PYTHON_COMPILE_FILES` (default: empty) |
| 22 | +- `CI_PYTHON_COVERAGE_TARGET` (default: empty) |
| 23 | +- `CI_PYTHON_COVERAGE_THRESHOLD` (default: `85`) |
| 24 | +- `CI_FRONTEND_NODE_VERSION` (default: `22`) |
| 25 | +- `CI_FRONTEND_WORKDIR` (default: `frontend`) |
| 26 | + |
| 27 | +## Optional secret |
| 28 | + |
| 29 | +- `GITLEAKS_LICENSE` is optional. If not set, the gitleaks step still runs with default behavior. |
| 30 | + |
| 31 | +## Auto-detection behavior |
| 32 | + |
| 33 | +The CI workflow detects project components and only runs relevant jobs: |
| 34 | + |
| 35 | +- Python jobs run if `pyproject.toml`, `setup.py`, or `requirements.txt` exists. |
| 36 | +- Frontend jobs run if `${CI_FRONTEND_WORKDIR}/package.json` exists. |
| 37 | +- Frontend E2E runs only when frontend exists, Python exists, and a Playwright config exists in frontend workdir. |
| 38 | +- Docker jobs run only when `Dockerfile` exists. |
| 39 | + |
| 40 | +## Release/container behavior |
| 41 | + |
| 42 | +- `docker-build` runs on pull requests (build only, no push). |
| 43 | +- `docker-push` runs on: |
| 44 | + - push to `main` |
| 45 | + - tag push matching `v*` |
| 46 | + - release published |
| 47 | +- GitHub release job runs on `v*` tag pushes after quality gate and Docker push succeed. |
| 48 | + |
| 49 | +## Suggested template usage |
| 50 | + |
| 51 | +1. Copy `.github/workflows/*` into the template repository. |
| 52 | +2. Configure repo variables listed above (only if defaults do not fit). |
| 53 | +3. Add optional secrets (for example `GITLEAKS_LICENSE`) as needed. |
| 54 | +4. Ensure your repo uses expected conventions: |
| 55 | + - Python package config at root. |
| 56 | + - Frontend at `frontend/` (or override with `CI_FRONTEND_WORKDIR`). |
| 57 | + - `Dockerfile` at root for Docker jobs. |
| 58 | + |
| 59 | +## Deploy workflows |
| 60 | + |
| 61 | +The deploy workflows in `.github/workflows/deploy-staging.yml` and `.github/workflows/deploy-production.yml` are template-ready and derive naming from repo/org by default. |
| 62 | + |
| 63 | +- Staging namespace: `<org-prefix>-staging` (example: `graphras-staging`) |
| 64 | +- Production namespace: `<org-prefix>-prod` (example: `graphras-prod`) |
| 65 | +- Container image: `ghcr.io/<org-ghcr>/<app-name>:<tag>` |
| 66 | +- Staging host: `staging-<app-name>.<org-dns>` |
| 67 | +- Production host: `<app-name>.<org-dns>` |
| 68 | +- Staging deploy image tag: `staging` (published on `main` pushes) |
| 69 | +- Production deploy image tag: release tag (e.g. `1.2.3` from `v1.2.3`) |
| 70 | + |
| 71 | +Trigger behavior: |
| 72 | + |
| 73 | +- Staging deploy runs via `workflow_call` from `ci.yml` after `docker-push` succeeds on `main`, or via `workflow_dispatch` (manual). |
| 74 | +- Production deploy runs via `workflow_call` from `ci.yml` after `docker-push` succeeds on a `v*` tag push, or via `workflow_dispatch`. |
| 75 | +- All deploy secrets are configured in GitHub Actions environments (`staging` and `production`). |
| 76 | + |
| 77 | +Optional environment variable overrides (set in GitHub Actions environment secrets): |
| 78 | + |
| 79 | +- `APP_NAME` (default: repository name) |
| 80 | +- `ORG_GHCR` (default: GitHub org slug, e.g. `graphras-com`) |
| 81 | +- `ORG_DNS` (default heuristic from `ORG_GHCR`, e.g. `graphras.com`) |
| 82 | +- `ORG_NS` (default: `ORG_GHCR` stripped of common TLD suffixes, e.g. `graphras`) |
| 83 | + |
| 84 | +This split handles GitHub org slug vs DNS domain naming (for example `graphras-com` -> `graphras.com`). |
0 commit comments