Skip to content

Lesson 3: CI/CD Integration

Running ReArch manually is fine for one-off tasks, but the real power comes from automation. In this lesson, you will wire ReArch into your CI/CD pipeline so tasks are triggered automatically by events like new issues, failed tests, or scheduled maintenance.

Add the ReArch GitHub Action to your workflow:

.github/workflows/rearch.yml
name: ReArch Agent
on:
issues:
types: [labeled]
schedule:
- cron: "0 9 * * 1" # Every Monday at 9am
permissions:
contents: write
pull-requests: write
issues: read
jobs:
rearch:
runs-on: ubuntu-latest
if: github.event.label.name == 'rearch' || github.event_name == 'schedule'
steps:
- uses: actions/checkout@v4
- name: Run ReArch
uses: lab34-es/rearch-action@v1
with:
api_key: ${{ secrets.REARCH_API_KEY }}
task: |
${{ github.event.issue.title }}
${{ github.event.issue.body }}
pipeline: feature
create_pr: true
  1. A team member creates an issue and adds the rearch label
  2. The GitHub Action triggers and passes the issue title + body as the task description
  3. ReArch processes the task and creates a pull request
  4. The team reviews and merges as normal

Use the schedule trigger for recurring maintenance:

# Weekly dependency updates
- name: Run ReArch
uses: lab34-es/rearch-action@v1
with:
api_key: ${{ secrets.REARCH_API_KEY }}
task: "Update all npm dependencies to their latest compatible versions. Run tests and fix any breaking changes."
pipeline: maintenance

Prevent the agent from creating PRs that do not meet your standards:

.rearch/pipelines/feature.yaml
pipeline:
name: feature
gates:
- name: tests
command: "npm test"
required: true
- name: lint
command: "npm run lint"
required: true
- name: type-check
command: "npx tsc --noEmit"
required: true
- name: coverage
command: "npm run test:coverage"
threshold: 80
required: false # Warn but don't block
- name: bundle-size
command: "npm run build && npx bundlesize"
required: false

If a required gate fails, the agent will attempt to fix the issue and re-run. After 3 failed attempts, the task is marked as needs_review and you are notified.

Configure notifications for task lifecycle events:

.rearch/config.yaml
notifications:
slack:
webhook: ${{ SLACK_WEBHOOK_URL }}
events:
- task_completed
- task_failed
- pr_created
- gate_failed
email:
recipients:
- team@example.com
events:
- task_failed

ReArch also works with GitLab CI:

.gitlab-ci.yml
rearch:
image: lab34/rearch-runner:latest
stage: automation
rules:
- if: '$CI_PIPELINE_SOURCE == "trigger"'
script:
- rearch task create --description "$TASK_DESCRIPTION" --pipeline feature
- rearch task wait --timeout 30m
variables:
REARCH_API_KEY: $REARCH_API_KEY

For custom integrations, use the webhook API:

Terminal window
curl -X POST https://api.rearch.engineer/v1/tasks \
-H "Authorization: Bearer $REARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "my-project",
"description": "Fix the failing test in auth.test.ts",
"pipeline": "bugfix",
"callback_url": "https://my-app.com/webhooks/rearch"
}'

The callback URL receives status updates as the task progresses.

You have completed the Advanced AI Workflows course. You now know how to:

  • Write custom system prompts that encode your team’s standards
  • Coordinate agents across multiple repositories and monorepos
  • Automate tasks through CI/CD pipelines with quality gates and notifications