Split workflow into validate (PR + act) and update (dev bot PR). Add structure checks per GitHub docs, API error validation, and act config.
132 lines
3.8 KiB
YAML
132 lines
3.8 KiB
YAML
name: Update CODEOWNERS
|
|
|
|
on:
|
|
workflow_dispatch: {}
|
|
pull_request:
|
|
paths:
|
|
- CODEOWNERS
|
|
- packages/widgets/src/**
|
|
- packages/integrations/src/**
|
|
- packages/api/src/router/widgets/**
|
|
- packages/cron-jobs/src/jobs/**
|
|
- scripts/generate-codeowners.mts
|
|
- scripts/validate-codeowners.mts
|
|
- scripts/codeowners-overrides.json
|
|
push:
|
|
paths:
|
|
- packages/widgets/src/**
|
|
- packages/integrations/src/**
|
|
- packages/api/src/router/widgets/**
|
|
- packages/cron-jobs/src/jobs/**
|
|
- scripts/generate-codeowners.mts
|
|
- scripts/validate-codeowners.mts
|
|
- scripts/codeowners-overrides.json
|
|
branches:
|
|
- dev
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
validate:
|
|
name: Validate CODEOWNERS
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .nvmrc
|
|
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Check CODEOWNERS is up to date
|
|
run: pnpm exec tsx ./scripts/generate-codeowners.mts --check
|
|
|
|
- name: Validate CODEOWNERS
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
run: pnpm exec tsx ./scripts/validate-codeowners.mts
|
|
|
|
update:
|
|
name: Open CODEOWNERS update PR
|
|
needs: validate
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
concurrency:
|
|
group: update-codeowners
|
|
cancel-in-progress: false
|
|
steps:
|
|
- name: Obtain token
|
|
id: obtainToken
|
|
uses: actions/create-github-app-token@v3
|
|
with:
|
|
private-key: ${{ secrets.HOMARR_UPDATE_CONTRIBUTORS_PRIVATE_KEY }}
|
|
client-id: ${{ vars.HOMARR_UPDATE_CONTRIBUTORS_APP_ID }}
|
|
permission-contents: write
|
|
permission-pull-requests: write
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
|
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .nvmrc
|
|
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Generate CODEOWNERS
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
|
run: pnpm scripts:generate-codeowners
|
|
|
|
- name: Validate CODEOWNERS
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
run: pnpm exec tsx ./scripts/validate-codeowners.mts
|
|
|
|
- name: Create Pull Request
|
|
id: create-pull-request
|
|
uses: peter-evans/create-pull-request@v8
|
|
with:
|
|
token: ${{ steps.obtainToken.outputs.token }}
|
|
branch: update-codeowners
|
|
base: dev
|
|
title: "chore: update widget/integration CODEOWNERS"
|
|
delete-branch: true
|
|
commit-message: "chore: update widget/integration CODEOWNERS"
|
|
body: |
|
|
This PR updates per-widget and per-integration CODEOWNERS entries from git history.
|
|
|
|
Unmapped authors can be added in `scripts/codeowners-overrides.json`.
|
|
|
|
- name: Install GitHub CLI
|
|
run: sudo apt-get install -y gh
|
|
|
|
- name: Enable auto-merge
|
|
if: steps.create-pull-request.outputs.pull-request-number != ''
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
|
run: |
|
|
gh pr merge ${{ steps.create-pull-request.outputs.pull-request-number }} --auto --squash
|