[FFmpeg-cvslog] forgejo/workflows: add issue/PR auto labeler
Timo Rothenpieler
git at videolan.org
Sat Jul 26 15:47:34 EEST 2025
ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Thu Jul 24 02:48:18 2025 +0200| [2513f3d60402abe09584ee25f658844573430d41] | committer: Timo Rothenpieler
forgejo/workflows: add issue/PR auto labeler
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2513f3d60402abe09584ee25f658844573430d41
---
.forgejo/labeler/labeler.js | 36 ++++++++++++++++++++++++++++++++++++
.forgejo/labeler/labeler.yml | 31 +++++++++++++++++++++++++++++++
.forgejo/workflows/autolabel.yml | 28 ++++++++++++++++++++++++++++
3 files changed, 95 insertions(+)
diff --git a/.forgejo/labeler/labeler.js b/.forgejo/labeler/labeler.js
new file mode 100644
index 0000000000..7e17c4167c
--- /dev/null
+++ b/.forgejo/labeler/labeler.js
@@ -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,
+ });
+ }
+}
diff --git a/.forgejo/labeler/labeler.yml b/.forgejo/labeler/labeler.yml
new file mode 100644
index 0000000000..9c4721cf29
--- /dev/null
+++ b/.forgejo/labeler/labeler.yml
@@ -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/**
diff --git a/.forgejo/workflows/autolabel.yml b/.forgejo/workflows/autolabel.yml
new file mode 100644
index 0000000000..0009550c05
--- /dev/null
+++ b/.forgejo/workflows/autolabel.yml
@@ -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 at 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})
More information about the ffmpeg-cvslog
mailing list