-
-
Notifications
You must be signed in to change notification settings - Fork 131
38 lines (36 loc) · 1.19 KB
/
add-feature-label.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Add Feature label
on:
- pull_request_target
jobs:
add-feature-label:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Find new files in src directory
run: |
NEW_FILES=$(git diff --name-only HEAD^ HEAD)
CHANGED_FILES=()
for file in $NEW_FILES; do
if [[ $file == "src/"* ]]; then
CHANGED_FILES+=("$file")
fi
done
echo "::set-output name=changed_files::${CHANGED_FILES[*]}"
id: find-files
- name: Add Feature label
if: ${{ steps.find-files.outputs.changed_files != '' }}
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = await github.issues.get(context.issue);
const labels = issue.data.labels.map(label => label.name);
if (!labels.includes('Feature')) {
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['Feature']
});
}