CollabOps

Scheduled Pipeline

Pipeline examples that run on a cron schedule — nightly builds, security scans, reports

Pipeline examples that run on a regular schedule using cron.

Nightly Build + Integration Tests

Runs the full test suite every day at midnight (UTC) and sends results to Slack.

name: nightly-build

triggers:
  schedule:
    branch: main                   # Runs against the main branch
    cron:
      - "0 0 * * *"               # Every day at midnight UTC (9 AM KST)

jobs:
  # ─────────────────────────────────────────
  # 1. Source code checkout (full history)
  # ─────────────────────────────────────────
  checkout:
    phase: source
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
          fetch-depth: "0"         # Full history (for coverage comparison)

  # ─────────────────────────────────────────
  # 2. Install dependencies
  # ─────────────────────────────────────────
  install:
    phase: deps
    needs: [checkout]
    steps:
      - name: npm-ci
        image: node:18
        run: |
          cd /workspace/source
          npm ci                   # Clean install (based on lock file)

  # ─────────────────────────────────────────
  # 3. Lint + type check
  # ─────────────────────────────────────────
  lint:
    phase: test
    needs: [install]
    steps:
      - name: eslint
        image: node:18
        run: |
          cd /workspace/source
          npm run lint             # Full ESLint check
      - name: typecheck
        image: node:18
        run: |
          cd /workspace/source
          npx tsc --noEmit         # TypeScript type check (no output)

  # ─────────────────────────────────────────
  # 4. Full test (with coverage)
  # ─────────────────────────────────────────
  test:
    phase: test
    needs: [install]
    steps:
      - name: full-test
        id: test-result
        image: node:18
        run: |
          cd /workspace/source

          # Run full tests + generate coverage report
          npm test -- --coverage --verbose 2>&1 | tee /tmp/test-output.txt

          # Extract coverage percentage (based on Statements)
          COVERAGE=$(grep 'Statements' /tmp/test-output.txt | grep -oP '\d+\.\d+' | head -1 || echo "N/A")
          echo "coverage=${COVERAGE}%" >> $COLLABOPS_OUTPUT
        env:
          CI: "true"

  # ─────────────────────────────────────────
  # 5. Build verification
  # ─────────────────────────────────────────
  build:
    phase: build
    needs: [lint, test]            # After both lint + test pass
    steps:
      - name: build
        image: node:18
        run: |
          cd /workspace/source
          npm run build

  # ─────────────────────────────────────────
  # 6. Result notification
  # ─────────────────────────────────────────
  notify:
    needs: [build]
    if: "always()"                 # Always notify regardless of success/failure
    steps:
      - name: slack-notify
        uses: "collabops/slack-notify@v1"
        with:
          webhook-url: ${{ secrets.SLACK_WEBHOOK }}
          title: "Nightly Build Report"
          message: |
            Branch: ${{ collabops.ref_name }}
            Commit: ${{ collabops.sha }}
          color: good

Multiple Schedules Example

triggers:
  schedule:
    branch: main
    cron:
      - "0 0 * * *"              # Every day at midnight — full tests
      - "0 12 * * 1-5"           # Weekdays at noon — additional verification

Schedule + Manual Execution Combination

By setting up both schedule and manual execution, you can trigger runs manually whenever needed in addition to the regular schedule.

triggers:
  schedule:
    branch: main
    cron: ["0 0 * * *"]          # Automatic daily execution

  workflow_dispatch:               # + Manual execution also available

Table of Contents