This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
60 lines (51 loc) · 1.99 KB
/
challenge-not-completed.yaml
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
name: On Challenge Not Completed
on:
workflow_dispatch:
inputs:
prId:
description: PR ID
required: true
default: ''
labelsToAdd:
description: The comma delimited labels to add
required: true
default: record-updated
labelsToRemove:
description: The comma delimited labels to remove
required: true
default: review-completed
isMergeable:
description: The value indicating whether the challenge is mergeable or not.
required: true
default: 'false'
jobs:
update_labels:
name: 'Update labels'
runs-on: ubuntu-latest
steps:
- name: Update labels on PR
shell: pwsh
run: |
$headers = @{ "Authorization" = "token ${{ secrets.GITHUB_TOKEN }}"; "User-Agent" = "HackaLearn Bot"; "Accept" = "application/vnd.github.v3+json" }
$owner = "devrel-kr"
$repository = "HackaLearn"
$issueId = "${{ github.event.inputs.prId }}"
$labelsToAdd = "${{ github.event.inputs.labelsToAdd }}" -split ","
$body = @{ "labels" = $labelsToAdd }
$url = "https://api.github.com/repos/$owner/$repository/issues/$issueId/labels"
Invoke-RestMethod -Method Post -Uri $url -Headers $headers -Body $($body | ConvertTo-Json)
$labelsToRemove = "${{ github.event.inputs.labelsToRemove }}" -split ","
$labelsToRemove | ForEach-Object {
$label = $_;
$url = "https://api.github.com/repos/$owner/$repository/issues/$issueId/labels/$label";
Invoke-RestMethod -Method Delete -Uri $url -Headers $headers
}
# - name: Update labels on PR
# uses: justinyoo/github-issue-label-action@v1
# with:
# authToken: ${{ secrets.GITHUB_TOKEN }}
# owner: 'devrel-kr'
# repository: HackaLearn
# issueId: '${{ github.event.inputs.prId }}'
# labelsToAdd: '${{ github.event.inputs.labelsToAdd }}'
# labelsToRemove: '${{ github.event.inputs.labelsToRemove }}'