CI/CD guide with GitHub Actions — phases 0, 1 and 2, commands and security
Audience: developers and project managers whose repository lives on GitHub (
ecosystem.config.json → cicd.platform: github-actions). This is the equivalent reading toGUIA_COMPLETA_CICD.md+GUIA_FASES_ADOPCION.md, which follow the Azure DevOps case. The phases, the commands and the invariants are the same; what changes is what you need from the platform and the shape of the files. Generated by Ovillo.
1. The general idea
With /hv:cicd-init, Ovillo generates one pipeline per deployable entrypoint (R25) under .github/workflows/, with the on-demand model (G1): a push to the base branch builds and tests; the deployment to dev/pre/pro is requested with /hv:cicd-deploy (or Actions → Run workflow). "Releasing" (/hv:cicd-release) means tagging a semver version, building it and creating the GitHub Release; it does not deploy.
| Command | What it does on GitHub | When | |
|---|---|---|---|
/hv:cicd-init | Generates ci.yml (phase 1) or cd-<slug>.yml + a reusable workflow + composite actions (phase 2); creates environments and secrets with gh; records it in the Hilo and in the Hub | When adopting CI/CD or promoting a phase | |
/hv:cicd-status | Runs (gh run list/view), time per job, last deployment per environment, runs waiting for approval, template drift | To see how the pipeline is doing | |
/hv:cicd-release | Annotated tag + push (triggers build) + gh release create --generate-notes | When marking a version | |
/hv:cicd-deploy | `gh workflow run cd-<slug>.yml --ref <branch\ | tag> -f environment=<env>` and follows the run | When promoting an artifact to an environment |
2. What you need in each phase
| Phase 0 (manual deploy) | Phase 1 (build validation) | Phase 2 (full CD) | |
|---|---|---|---|
| Repository on GitHub | ✅ | ✅ | ✅ |
gh authenticated (gh auth login) | ❌ | ✅ (for rulesets and checks over the API) | ✅ (environments, secrets) |
| Runner | ❌ | hosted (ubuntu-latest/windows-latest) or self-hosted | the same; deploying to on-premise IIS requires a self-hosted runner with access to the server |
Base-branch ruleset with the Build/Security checks | recommended | ✅ (git-best-practices) | ✅ |
Environments dev/pre/pro | ❌ | ❌ | ✅; reviewers on pre/pro only on public repositories or Team/Enterprise plans (on Free private, the gate is the workflow_dispatch itself) |
| Secrets per environment | ❌ | ❌ | ✅ (gh secret set <KEY> --env <env>) |
| Cloud identity | ❌ | ❌ | OIDC (id-token: write + a federated credential) if the target is Azure/AWS; credentials only if there is no alternative (G18) |
| Ovillo Hub (quality record) | ❌ | ❌ | optional: secret HUB_SERVICE_KEY + variable HUB_PROJECT_ID |
There is no pool to authorize and no agents to install (unless self-hosted): what on Azure was a handoff to the infrastructure team is here admin permission on the repository (environments, secrets, rulesets) and, for Projects v2 and organization runners, organization owner (see PERMISOS_CICD.md § GitHub).
3. What /hv:cicd-init generates
| Phase / stack | Files | Notes |
|---|---|---|
| Phase 1 .NET | .github/workflows/ci.yml | jobs Build (restore/build/test/coverage) and Security (dotnet list package --vulnerable, fails on Critical/High). These are the checks the ruleset requires. In phase 2 it loses the push trigger and stays for PRs and the merge queue |
| Phase 2 .NET | .github/workflows/cd-<slug>.yml · _reusable-dotnet-build.yml · .github/actions/{security-scan,security-gate,quality-sync} | one cd-*.yml per entrypoint; a reusable build; jobs deploy-dev/pre/pro with environment: and if: workflow_dispatch && inputs.environment == '<env>' |
| Vue 3 + Vite | cd-<slug>.yml | npm ci + lint + test + build; best-effort smoke |
| .NET tool / library | publish-nuget.yml | a v* tag publishes the .nupkg (GitHub Packages or NuGet.org) |
| Opt-in security | security.yml | CodeQL + dependency review; only if the repository is public or has GHAS (§ 6) |
| Scripts in the repository | ops/cicd/scripts/security-scan.ps1, Sync-QualityRecord.ps1 | CI cannot read the plugin: /hv:cicd-init copies them |
| Documentation | ops/cicd/RUNBOOK.md, PERMISOS_CICD.md, SEGURIDAD_PIPELINE.md | adapted to the project |
Every workflow carries the stamp # Ovillo cicd-architect github-<stack> @ …; /hv:cicd-status warns about drift when the template changes, and /hv:cicd-init option 4 re-renders it.
4. Deployment model and rollback
- On-demand (default):
deploy-<env>only runs withworkflow_dispatchandinputs.environment == '<env>'. - Auto:
deploy-devwithif: github.event_name == 'push';pre/prostay on-demand. - Branch-gated (gitlab-flow/gitflow): plus
github.ref == 'refs/heads/<the environment's branch>'. - Double gate on pre/pro: the confirmation in
/hv:cicd-deployand the environment's required reviewers. Nobody approves their own environment from Ovillo: approval happens in Actions → Review deployments. - Rollback (G9): (1) the backup taken in the Deploy step; (2) redeploy the previous version:
/hv:cicd-deploy --env <env> --tag <previous>(=gh workflow run cd-<slug>.yml --ref <tag> -f environment=<env>); (3) by hand, followingops/cicd/RUNBOOK.md.
5. Invariants the workflow satisfies out of the box (G15-G19)
| Rule | In the generated YAML | |
|---|---|---|
| G15 | Least privilege | permissions: contents: read at the root; each job raises only what it uses (id-token: write in deploy, security-events: write in CodeQL) |
| G16 | Actions pinned by SHA | uses: owner/action@<sha40> # vX.Y.Z; Dependabot keeps them current (git-best-practices/templates/dependabot.yml.template) |
| G17 | No pull_request_target with a checkout of the fork, and no ${{ github.event.* }} inside run: | inputs through env: and "$VAR" |
| G18 | OIDC | id-token: write + azure/login/configure-aws-credentials with a federated credential |
| G19 | concurrency | cancel-in-progress: true in CI, false in CD |
Audit it with the github-actions-reviewer agent (see AUDITAR_PIPELINE.md); the ecosystem team maintains a linter with the same criteria.
6. Repository security (opt-in, with graceful degradation)
| Feature | Cost | How /hv:cicd-init turns it on (PHASE 2.5-gh) | If it is not available |
|---|---|---|---|
| Dependabot alerts | free | gh api -X PUT repos/{o}/{r}/vulnerability-alerts | — |
| Dependabot security updates | free | gh api -X PUT repos/{o}/{r}/automated-security-fixes | — |
| Dependabot version updates | free | .github/dependabot.yml (git-best-practices) | — |
| Dependency review on PRs | free (dependency graph) | the dependency-review job of security.yml | — |
| Secret scanning + push protection | free on public repos; GHAS on private | gh api -X PATCH repos/{o}/{r} --input security.json (security_and_analysis) | Ovillo's secret-scanner hook + G5 (secrets only through secrets.*) |
| Code scanning (CodeQL) | free on public repos; GHAS (Code Security) on private | security.yml (advanced setup, SHA-pinned) or gh api -X PATCH repos/{o}/{r}/code-scanning/default-setup -f state=configured | the G8 gate (security-scan.ps1: dependencies, secrets, hardening, CA5xxx SAST) + the Security job of ci.yml |
The rule: /hv:cicd-init tries the call and branches on the status code, not on the error text. Measured against a private repository without GHAS: secret scanning returns 422 "Secret scanning is not available for this repository" and code scanning 403 "Code scanning is not enabled for this repository"; Dependabot (alerts and security updates) returns 204 and works. On a 403 or a 422 it does not materialize security.yml, records it in ops/cicd/SEGURIDAD_PIPELINE.md and carries on. It never blocks adoption over a licence.
7. Quality: publishing the quality record to the Hub
The quality job of cd-<slug>.yml (the quality-sync composite) publishes each build's quality record to the Ovillo Hub. It needs the secret HUB_SERVICE_KEY (the project's service key, not a developer's apiKey) and the variable HUB_PROJECT_ID. Two ways:
- Zero-touch:
/hv:cicd-initPHASE 2.7 materializes and runsops/cicd/provision-quality-ci-key.ps1(fromProvision-QualityCiKey.github.ps1.template): it asks the Hub for the key and stores it withgh secret setover stdin. The key is never printed. - By hand: the admin issues it (
EXEC mcp.EmitirServiceKey @Label='ci-quality') andgh secret set HUB_SERVICE_KEY < key.txt.
Without the key, the job warns and exits green: quality does not gate the build.
8. Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
gh workflow run: Workflow does not have 'workflow_dispatch' trigger, or a 404 | The file is not on the default branch, or it has no such trigger | Merge cd-<slug>.yml into main; /hv:cicd-init option 4 |
The run stays in waiting | An environment with reviewers | A reviewer approves it in Actions → Review deployments |
No deploy-* job runs after the dispatch | inputs.environment does not match the if: conditions; branch-gated with a --ref from another branch | Check options: [dev, pre, pro]; use the environment's branch |
Resource not accessible by integration | The gh token lacks the workflow scope, or Actions are disabled | gh auth refresh -s workflow; Settings → Actions |
| The ruleset does not require the checks | The check name ≠ the job's name: (Build, Security) | Align required_status_checks.contexts with the job names |
CodeQL fails in analyze | A private repository without GHAS | Remove security.yml; G8 + Dependabot remain |
| The quality record is not published | HUB_SERVICE_KEY or HUB_PROJECT_ID is missing | § 7 |
/hv:cicd-status reports drift | The stack's template changed | /hv:cicd-init option 4 (re-render + self-check -GitHub) |
Ovillo guide — CI/CD with GitHub Actions. For the Azure DevOps case: GUIA_COMPLETA_CICD.md, GUIA_FASES_ADOPCION.md.
Fuente: ovillo/_patron/08_CICD/GUIA_GITHUB_ACTIONS_EN.md