-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (47 loc) · 1.85 KB
/
add-issue-to-memex-by-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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Add Issue to Memex by Label
on:
issues:
types: [labeled]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
name: Checkout powershell tools
with:
repository: cmbrose/github-projects-powershell
path: ./github-projects-powershell
- uses: Amadevus/pwsh-script@v2
name: Run script
env:
PROJECTS_VNEXT_GRAPHQL_PAT: ${{ secrets.PROJECTS_VNEXT_GRAPHQL_PAT }}
with:
script: |
$labelToMemexIdMap = @{
"bug" = 111;
"todo" = 222;
}
cd ./github-projects-powershell
Import-Module .\common\client.psm1
Import-Module .\types\project-vnext.psm1
$client = New-GraphQLClient -token $env:PROJECTS_VNEXT_GRAPHQL_PAT
$org, $repo = $github.event.repository.full_name.split("/")
$issueNumber = $github.event.issue.number
$issueId = $github.event.issue.node_id
$label = $github.event.label.name
$targetProject = $labelToMemexIdMap[$label]
if (-not $targetProject) {
Write-ActionInfo "Label '$label' did not have a target project, nothing to do"
return
}
$proj = Get-Project -org $org -projectNumber $targetProject -client $client
Write-ActionInfo "Loaded project #$targetProject"
$item = $proj.Items | where { $_.content.id -eq $issueId }
if (-not $item) {
Write-ActionInfo "Adding issue #$issueNumber to the project"
$item = $proj.AddItemByContentId($issueId)
} else {
Write-ActionInfo "Issue #$issueNumber is already on the project"
}
# Can edit $item here to set fields...
Write-ActionInfo "Complete"