fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes Altmanningerbuild_tools/update-dependencies.sha3b009dd4

master
1.4 KiB40 linesraw
1name: Auto-Label PRs
2
3on:
4  pull_request_target:
5    types: [opened, synchronize]
6
7jobs:
8  label-and-milestone:
9    runs-on: ubuntu-latest
10    steps:
11    - name: Set label and milestone
12      id: set-label-milestone
13      uses: actions/github-script@d746ffe35508b1917358783b479e04febd2b8f71 # v9.0.0, build_tools/update-dependencies.sh
14      with:
15        script: |
16          const completionsLabel = 'completions';
17
18          // Get changed files in the pull request
19          const prNumber = context.payload.pull_request.number;
20          const { data: files } = await github.rest.pulls.listFiles({
21            owner: context.repo.owner,
22            repo: context.repo.repo,
23            pull_number: prNumber,
24          });
25
26          // Check if any file matches /share/completions/*.fish and no change is outside of /share/
27          const completionsRegex = new RegExp('^share/completions/.*\.fish');
28          const isCompletions = files.some(file => completionsRegex.test(file.filename))
29            && files.every(file => file.filename.startsWith('share/'));
30
31          if (isCompletions) {
32            // Add label to PR
33            await github.rest.issues.addLabels({
34              owner: context.repo.owner,
35              repo: context.repo.repo,
36              issue_number: prNumber,
37              labels: [completionsLabel],
38            });
39            console.log(`PR ${prNumber} assigned label "${completionsLabel}"`);
40          }