-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (60 loc) · 2.19 KB
/
auto-change-pr.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Automatically labeling pull request.
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
auto-change-pr:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_ASSIGNEE: ${{ github.event.pull_request.user.login }}
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
steps:
- uses: actions/checkout@v2
# 変更されたファイルを取得
- name: get changed files
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
frontend:
- 'frontend/**'
backend:
- 'api/**'
- 'auth/**'
infra:
- 'cloudflare/**'
- 'docker-compose.*'
- '**/*Dockerfile'
# ブランチ名からラベル名を取得
- uses: actions/github-script@v6
id: label_name
with:
github-token: ${{ env.GH_TOKEN }}
script: |
const env = process.env;
const branchType = env.PR_BRANCH.split('/')[0]
const branchTypeToLabel = {
feature: 'enhancement',
fix: 'bug',
hotfix: 'bug',
};
core.setOutput('label_name', branchTypeToLabel[branchType] || '')
# PRにラベルを付与
- name: Auto frontend labeling
if: steps.changes.outputs.frontend == 'true'
run: gh pr edit ${{ env.PR_NUMBER }} --add-label frontend
- name: Auto backend labeling
if: steps.changes.outputs.backend == 'true'
run: gh pr edit ${{ env.PR_NUMBER }} --add-label backend
- name: Auto infra labeling
if: steps.changes.outputs.infra == 'true'
run: gh pr edit ${{ env.PR_NUMBER }} --add-label infra
- name: Auto labeling
if: steps.label_name.outputs.label_name
run: gh pr edit ${{ env.PR_NUMBER }} --add-label ${{ steps.label_name.outputs.label_name }}
# PRにAssigneeを付与
- name: Auto assignee
if: toJSON(github.event.pull_request.assignees) == '[]'
run: gh pr edit ${{ env.PR_NUMBER }} --add-assignee ${{ env.PR_ASSIGNEE }}