Skip to main content

CI/CD (push mode)

This page describes a CI/CD pattern where Ogoron pushes its outputs to a new branch in the same repository.

The default flow is:

  1. Check out the repository branch that triggered the CI job
  2. Run ogoron analyze business
  3. Run generation commands
  4. Commit a curated set of files
  5. Push a new branch named base_branch-ogoron-N

Creating an MR/PR is optional.

What to commit

Recommended commit scope:

  • .ogoron/keep-git/**
  • the tests directory from config.yml: paths.tests

Branch naming

  • base_branch is the branch that triggered the CI job.
  • N is a unique run number (pipeline id / workflow run number).

Example:

feature-login-ogoron-12345

GitLab CI template (push branch)

ogoron_push:
stage: test
image: docker:27
services:
- docker:27-dind
variables:
GIT_STRATEGY: fetch
DOCKER_TLS_CERTDIR: "/certs"
script:
- docker --version
- apk add --no-cache git

# Run Ogoron in a container and mount the repository.
# OGORON_IMAGE is provided during onboarding.
- |
docker run --rm \
-e OGORON_KEY="$OGORON_KEY" \
-v "$CI_PROJECT_DIR:/repo" \
-w /repo \
"$OGORON_IMAGE" \
ogoron init
- |
docker run --rm \
-e OGORON_KEY="$OGORON_KEY" \
-v "$CI_PROJECT_DIR:/repo" \
-w /repo \
"$OGORON_IMAGE" \
ogoron analyze business
- |
docker run --rm \
-e OGORON_KEY="$OGORON_KEY" \
-v "$CI_PROJECT_DIR:/repo" \
-w /repo \
"$OGORON_IMAGE" \
ogoron generate test-cases --by-text "Describe what should be tested"

# Commit only curated outputs:
- git config user.email "ogoron-bot@example.com"
- git config user.name "ogoron-bot"

# Normalize branch name (replace slashes).
- BASE_BRANCH="$(echo "$CI_COMMIT_REF_NAME" | tr '/' '-')"
- OUT_BRANCH="${BASE_BRANCH}-ogoron-${CI_PIPELINE_ID}"

- git checkout -b "$OUT_BRANCH"
- git add .ogoron/keep-git || true
# If your tests directory is not `tests`, update this path to match your repository.
- git add tests || true
- git commit -m "Ogoron outputs [skip ci]" || echo "No changes to commit"

# Push (requires repository write access; see tokens page).
# Use a masked CI variable for GITLAB_TOKEN.
- git remote set-url origin "https://oauth2:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
- git push -u origin "$OUT_BRANCH"
rules:
- when: manual

GitHub Actions template (push branch)

name: ogoron

on:
workflow_dispatch:

permissions:
contents: write

jobs:
ogoron_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# If branch pushes are blocked for GITHUB_TOKEN in your repository, use a PAT stored in secrets.
# token: ${{ secrets.OGORON_GITHUB_TOKEN }}

- name: Run Ogoron
run: |
docker run --rm \
-e OGORON_KEY="$OGORON_KEY" \
-v "${GITHUB_WORKSPACE}:/repo" \
-w /repo \
"$OGORON_IMAGE" \
ogoron init
docker run --rm \
-e OGORON_KEY="$OGORON_KEY" \
-v "${GITHUB_WORKSPACE}:/repo" \
-w /repo \
"$OGORON_IMAGE" \
ogoron analyze business
docker run --rm \
-e OGORON_KEY="$OGORON_KEY" \
-v "${GITHUB_WORKSPACE}:/repo" \
-w /repo \
"$OGORON_IMAGE" \
ogoron generate test-cases --by-text "Describe what should be tested"

- name: Commit and push
env:
BASE_BRANCH: ${{ github.ref_name }}
RUN_NUMBER: ${{ github.run_number }}
run: |
git config user.email "ogoron-bot@example.com"
git config user.name "ogoron-bot"

SAFE_BASE_BRANCH="${BASE_BRANCH//\//-}"
OUT_BRANCH="${SAFE_BASE_BRANCH}-ogoron-${RUN_NUMBER}"

git checkout -b "$OUT_BRANCH"
git add .ogoron/keep-git || true
# If your tests directory is not `tests`, update this path to match your repository.
git add tests || true
git commit -m "Ogoron outputs [skip ci]" || echo "No changes to commit"
git push -u origin "$OUT_BRANCH"

Optional: create an MR/PR

To create an MR/PR automatically, the CI job needs additional permissions.

  • GitLab: API access is required to create a Merge Request.
  • GitHub: Pull request permissions are required to create a Pull Request.

Token and permissions guidance:

Notes

  • The GitLab template requires a runner that supports Docker-in-Docker or an environment with a working Docker daemon.
  • Avoid infinite CI loops by excluding the *-ogoron-* branches from running the same workflow, or by using commit messages that prevent CI from running.
  • If the generated tests directory is not tests, update the template to match your config.yml: paths.tests.