Repository navigation
115 lines (95 loc) · 3.49 KB
/
Copy pathpull_request.yaml
File metadata and controls
115 lines (95 loc) · 3.49 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: 'PR Automation'
on:
pull_request:
types: [ opened, ready_for_review ]
permissions: write-all
jobs:
comment-job:
name: 'Comment Job'
runs-on: ubuntu-latest
steps:
- name: Create comment
uses: actions/github-script@v7
with:
script: |
const creator = context.payload.sender.login
const opts = github.rest.issues.listForRepo.endpoint.merge({
...context.issue,
creator,
state: 'all'
})
const issues = await github.paginate(opts)
for (const issue of issues) {
if (issue.number === context.issue.number) {
continue
}
if (issue.pull_request) {
return // Creator is already a contributor.
}
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `👋 Welcome!
처음 오셨군요!
아직 익숙하지 않으실텐데요, 먼저 여기 [가이드](https://github.com/hackersground-kr/GithubWordRelay/blob/main/Policy.md)를 한번 봐주세요!
모르는게 있으면 언제든 편하게 질문해주시고 끝까지 잘 마무리 해 보아요~!`
})
- name: Apply assignee
uses: actions/github-script@v7
with:
script: |
const creator = context.payload.sender.login
github.rest.issues.addAssignees({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: [ creator ]
})
- name: Apply labels
uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['HackersGround_240525']
})
- name: Checkout auto-reviewer file
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/auto_assign.yml
sparse-checkout-cone-mode: false
- name: Check teams
shell: pwsh
run: |
# Check Modules
if (!(Get-Module -ListAvailable -Name powershell-yaml)) {
Install-Module powershell-yaml -Confirm:$False -Force
}
# Load Module
Import-Module powershell-yaml
[string] $reviewers = Get-Content -Path '.github/auto_assign.yml' -Raw
$yaml = ConvertFrom-Yaml -Yaml $reviewers -AllDocuments
[string] $reviewers = $yaml.GetEnumerator() |
Where-Object -Property Value -Value '${{ github.actor }}' -Contains |
Select-Object -Property Value -Unique -ExpandProperty Value |
? { $_.Split([Environment]::NewLine)} |
? { $_ -ne '${{ github.actor }}' } |
Join-String -Separator ',' -SingleQuote
$githubEnv = [System.Environment]::GetEnvironmentVariable('GITHUB_ENV')
Write-Output TARGET_REVIEWERS=$reviewers >> $githubEnv
#[System.Environment]::SetEnvironmentVariable('TARGET_REVIEWERS', $reviewers)
- name: Request reviewers
uses: actions/github-script@v7
with:
script: |
github.rest.pulls.requestReviewers({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
reviewers: [ ${{ env.TARGET_REVIEWERS }} ]
})