|
|
@@ -0,0 +1,59 @@
|
|
|
+# 🤬 https://github.com/actions/labeler/issues/12 / https://github.community/t5/GitHub-Actions/GitHub-actions-are-severely-limited-on-PRs/m-p/54669/highlight/true#M9249
|
|
|
+# (this workflow shouldn't exist)
|
|
|
+
|
|
|
+name: Label PRs
|
|
|
+
|
|
|
+on:
|
|
|
+ schedule:
|
|
|
+ - cron: '*/15 * * * *'
|
|
|
+
|
|
|
+defaults:
|
|
|
+ run:
|
|
|
+ shell: 'bash -Eeuo pipefail -x {0}'
|
|
|
+
|
|
|
+jobs:
|
|
|
+
|
|
|
+ label:
|
|
|
+ name: Label
|
|
|
+ runs-on: ubuntu-latest
|
|
|
+ steps:
|
|
|
+ - uses: actions/checkout@v2
|
|
|
+ - name: Apply Labels
|
|
|
+ uses: actions/[email protected]
|
|
|
+ with:
|
|
|
+ script: |
|
|
|
+ const { data: pulls } = await github.pulls.list({
|
|
|
+ owner: context.repo.owner,
|
|
|
+ repo: context.repo.repo,
|
|
|
+ state: 'open',
|
|
|
+ sort: 'updated',
|
|
|
+ direction: 'desc',
|
|
|
+ per_page: 100,
|
|
|
+ });
|
|
|
+ for (let i = 0; i < pulls.length; ++i) {
|
|
|
+ let pull = pulls[i];
|
|
|
+ const { data: files } = await github.pulls.listFiles({
|
|
|
+ owner: context.repo.owner,
|
|
|
+ repo: context.repo.repo,
|
|
|
+ pull_number: pull.number,
|
|
|
+ });
|
|
|
+ const currentLabels = pull.labels.map((label) => { return label.name });
|
|
|
+ const newLabels = files.map((file) => {
|
|
|
+ if (file.filename.startsWith('library/')) {
|
|
|
+ if (file.status === 'added') {
|
|
|
+ return [ file.filename, 'new-image' ];
|
|
|
+ } else {
|
|
|
+ return [ file.filename ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return [];
|
|
|
+ }).flat().filter((label) => { return !currentLabels.includes(label) });
|
|
|
+ if (newLabels.length > 0) {
|
|
|
+ await github.issues.addLabels({
|
|
|
+ owner: context.repo.owner,
|
|
|
+ repo: context.repo.repo,
|
|
|
+ issue_number: pull.number,
|
|
|
+ labels: newLabels,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|