Skip to content

campaigns: experiment with per-repo templates

Erik Seliger requested to merge aharvey/campaign-spec-experiment into main

Created by: LawnGnome

This is one possible approach to tackle sourcegraph/sourcegraph#13139, as described in RFC 228.

Basically, you can now replicate changesetTemplate in individual OnQueryOrRepository items. For example:

name: hello-world
description: Add Hello World to READMEs

# Find all repositories that contain a README.md file.
on:
  - repositoriesMatchingQuery: file:README.md r:github.com/LawnGnome
    changesetTemplate:
      title: Hello Adam
      body: Your first campaign?
      branch: hello-world # Push the commit to this branch.
      commit:
        message: Append Hello World to all README.md files
      published: true
  - repositoriesMatchingQuery: file:README.md r:gitlab.sgdev.org

# In each repository, run this command. Each repository's resulting diff is captured.
steps:
  - run: echo Hello World | tee -a $(find -name README.md)
    container: alpine:3

# Describe the changeset (e.g., GitHub pull request) you want for each repository.
changesetTemplate:
  title: Hello World
  body: My first campaign!
  branch: hello-world # Push the commit to this branch.
  commit:
    message: Append Hello World to all README.md files
  published: false

In the event that a repo is matched by more than one OnQueryOrRepository, the precedence is roughly (more detail in the RFC):

  1. repository: exact repo with a branch, with the tie breaker being the first item seen
  2. repository: exact repo without a branch
  3. repositoriesMatchingQuery: search string, with the tie breaker being the longer query
  4. The campaign spec changesetTemplate

Merge request reports

Loading