Skip to main content
Version: Next

CI Integration Guide

How to integrate lops into your CI/CD pipelines.

Exit Codes

CodeMeaningWhen
0SuccessAll files compliant (check) or all fixed (fix)
1Non-compliantFiles found with missing/incorrect headers
2ErrorBad config, IO error, invalid license
3Partial failureSome files errored and some are non-compliant

GitHub Actions

Basic Check

name: License Headers
on: [pull_request]

jobs:
license-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install lops
run: |
curl -sSL https://github.com/licenseops/licenseops/releases/latest/download/licenser_Linux_x86_64.tar.gz | tar xz
sudo mv lops /usr/local/bin/

- name: Check license headers
run: lops check

With Go Install

- uses: actions/setup-go@v5
with:
go-version: '1.26'

- name: Install lops
run: go install github.com/licenseops/licenseops/cmd/lops@latest

- name: Check license headers
run: lops check

With Docker

- name: Check license headers
run: |
docker run --rm \
-v "${{ github.workspace }}":/src \
-w /src \
ghcr.io/licenseops/licenseops check

Auto-Fix on PR (Commit Changes)

name: License Headers Fix
on: [pull_request]

permissions:
contents: write

jobs:
license-fix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Install lops
run: |
curl -sSL https://github.com/licenseops/licenseops/releases/latest/download/licenser_Linux_x86_64.tar.gz | tar xz
sudo mv lops /usr/local/bin/

- name: Fix license headers
run: lops fix

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'chore: fix license headers'

Combined with Other Checks

name: CI
on: [pull_request]

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Install lops
run: go install github.com/licenseops/licenseops/cmd/lops@latest

- name: License headers
run: lops check

- name: Lint
uses: golangci/golangci-lint-action@v6

- name: Test
run: go test ./... -race

GitLab CI

license-check:
image: golang:1.26-alpine
stage: lint
script:
- go install github.com/licenseops/licenseops/cmd/lops@latest
- lops check
rules:
- if: $CI_MERGE_REQUEST_ID

Pre-commit

Setup

Add to .pre-commit-config.yaml:

repos:
- repo: https://github.com/licenseops/licenseops
rev: v0.1.0
hooks:
- id: lops-check
name: Check license headers
entry: lops check
language: golang
additional_dependencies:
['github.com/licenseops/licenseops/cmd/lops@v0.1.0']
always_run: true
pass_filenames: false

Auto-fix Mode

repos:
- repo: https://github.com/licenseops/licenseops
rev: v0.1.0
hooks:
- id: lops-fix
name: Fix license headers
entry: lops fix
language: golang
additional_dependencies:
['github.com/licenseops/licenseops/cmd/lops@v0.1.0']
always_run: true
pass_filenames: false

Makefile Integration

Add these targets to your project's Makefile:

.PHONY: license-check license-fix

license-check: ## Check license headers
lops check

license-fix: ## Fix license headers
lops fix

Then use in CI:

- name: License check
run: make license-check

Docker Usage

Check a Local Project

docker run --rm -v "$(pwd)":/src -w /src ghcr.io/licenseops/licenseops check

Fix a Local Project

docker run --rm -v "$(pwd)":/src -w /src ghcr.io/licenseops/licenseops fix

With Custom Config

docker run --rm -v "$(pwd)":/src -w /src ghcr.io/licenseops/licenseops check -c my-config.yaml

Override All Settings via Flags

docker run --rm -v "$(pwd)":/src -w /src ghcr.io/licenseops/licenseops check \
-l "Apache-2.0" \
-o "My Org" \
-f spdx

Tips

  • Fail fast: Put the license check early in your pipeline — it's fast and catches common issues.
  • Config in repo: Commit .licenseops.yaml so CI and local dev use the same settings.
  • Dry run first: Use lops fix --dry-run in CI to report what would change without modifying files.
  • Verbose in CI: Use -v to see every file in CI logs for debugging.

See Also