-
Notifications
You must be signed in to change notification settings - Fork 38
102 lines (90 loc) · 4.37 KB
/
move-issues.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
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
name: Move Issues
on:
push:
paths:
- 'package.json'
env:
GH_TOKEN: ${{ secrets.TOKEN }}
jobs:
prerequisites:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- uses: actions/checkout@v3
# get version
- name: Get Version
id: version
run: |
V=$(jq .version package.json | sed 's/"//g')
echo "VERSION=v$V" >> $GITHUB_OUTPUT # for subsequent jobs
echo v$V
move-issues:
needs: prerequisites
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: process-issues
run: |
minorVersion=$(echo ${{ needs.prerequisites.outputs.VERSION }} | cut -d. -f1,2).x
# add gh extension
gh extension install heaths/gh-merge-json
# get issues from project
# gh api graphql --paginate -F user=Zefau -F project=2 -f query='
# query GetIssuesFromProject($user:String!,$project:Int!,$endCursor:String) {
# user(login: $user) {
# projectV2(number: $project) { # ProjectV2: https://docs.github.com/en/graphql/reference/objects#projectv2
# id,
# fields(first: 100) { # ProjectV2FieldConfigurationConnection
# totalCount
# nodes { # ProjectV2FieldConfiguration
# ... on ProjectV2SingleSelectField {
# id
# name
# dataType
# options { id name }
# }
# }
# }
# items(first: 100, after: $endCursor) {
# totalCount
# pageInfo { endCursor hasNextPage }
# nodes {
# id,
# content {
# ... on Issue {
# issueId: id
# number
# title
# labels(first: 100) {
# totalCount
# nodes { id name }
# }
# state
# }
# }
# status: fieldValueByName(name: "Status") {
# ... on ProjectV2ItemFieldSingleSelectValue { id name updatedAt }
# }
# version: fieldValueByName(name: "Version") {
# ... on ProjectV2ItemFieldSingleSelectValue { id name updatedAt }
# }
# }
# }
# }
# }
# }' | gh merge-json > issues.json
# extract issues (open issue in the project-status "IMPLEMENTED LOCALLY" matching the given version
# ISSUES=$(cat issues.json | jq .data.user.projectV2.items.nodes | jq --arg version "$minorVersion" -c '.[] | select(.content.state == "OPEN") | select(.status.name == "IMPLEMENTED LOCALLY") | select(.version.name == $version) | [ .id, .content.issueId, [.content.labels.nodes[].name] ]')
# extract values of field `released`
# FIELDS=$(cat issues.json | jq .data.user.projectV2.fields.nodes | jq -c '.[] | select(.name == "Released") | .options')
# FIELDS=$(echo $FIELDS | cut -d' ' -f1)
# get issues
gh issue list -L 9999 --json id,labels,number,state,title > issues.json
# extract issues [ by label "#status: implemented-locally" (LA_kwDODbcoCM8AAAABfBUbZQ) matching the given version by a dedicated label ]
ISSUES=$(cat issues.json | jq -c '.[] | select(.labels[].name == "#status: implemented-locally :hammer_and_wrench:") | select(.labels[].name == "v3.2") | [ .id, .number, [ .labels[].name ]]')
#
cd $GITHUB_WORKSPACE
cd .github && cd workflows
# node move-issues.js "${{ needs.prerequisites.outputs.VERSION }}" "$ISSUES" "$FIELDS"
node move-issues.js "${{ needs.prerequisites.outputs.VERSION }}" "$ISSUES"