1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

forgejo/workflows: add issue/PR auto labeler

This commit is contained in:
Timo Rothenpieler
2025-07-24 02:48:18 +02:00
parent e29016a9de
commit 2513f3d604
3 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,36 @@
module.exports = async ({github, context}) => {
const title = (context.payload.pull_request?.title || context.payload.issue?.title || '').toLowerCase();
const labels = [];
const kwmap = {
'avcodec': 'avcodec',
'avdevice': 'avdevice',
'avfilter': 'avfilter',
'avformat': 'avformat',
'avutil': 'avutil',
'swresample': 'swresample',
'swscale': 'swscale',
'fftools': 'CLI'
};
if (context.payload.action === 'opened') {
labels.push('new');
console.log('Detected label: new');
}
for (const [kw, label] of Object.entries(kwmap)) {
if (title.includes(kw)) {
labels.push(label);
console.log('Detected label: ' + label);
}
}
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request?.number || context.payload.issue?.number,
labels: labels,
});
}
}

View File

@ -0,0 +1,31 @@
avcodec:
- changed-files:
- any-glob-to-any-file: libavcodec/**
avdevice:
- changed-files:
- any-glob-to-any-file: libavdevice/**
avfilter:
- changed-files:
- any-glob-to-any-file: libavfilter/**
avformat:
- changed-files:
- any-glob-to-any-file: libavformat/**
avutil:
- changed-files:
- any-glob-to-any-file: libavutil/**
swresample:
- changed-files:
- any-glob-to-any-file: libswresample/**
swscale:
- changed-files:
- any-glob-to-any-file: libswscale/**
CLI:
- changed-files:
- any-glob-to-any-file: fftools/**

View File

@ -0,0 +1,28 @@
on:
pull_request_target:
types: [opened, edited, synchronize]
issues:
types: [opened, edited]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
pr_labeler:
runs-on: utilities
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Label by file-changes
uses: https://github.com/actions/labeler@v5
if: ${{ forge.event_name == 'pull_request_target' }}
with:
configuration-path: .forgejo/labeler/labeler.yml
- name: Label by title-match
uses: https://github.com/actions/github-script@v7
with:
script: |
const script = require('.forgejo/labeler/labeler.js')
await script({github, context})