1+ name : Add to Project
2+
3+ on :
4+ issues :
5+ types : [opened, labeled]
6+ pull_request :
7+ types : [opened, labeled]
8+
9+ jobs :
10+ add-to-project :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/add-to-project@v1.0.2
14+ id : add
15+ with :
16+ project-url : https://github.com/orgs/AzureLocal/projects/3
17+ github-token : ${{ secrets.ADD_TO_PROJECT_PAT }}
18+
19+ set-fields :
20+ needs : add-to-project
21+ runs-on : ubuntu-latest
22+ if : always() && github.event_name == 'issues'
23+ env :
24+ GH_TOKEN : ${{ secrets.ADD_TO_PROJECT_PAT }}
25+ PROJECT_ID : " PVT_kwDOCxeiOM4BR2KZ"
26+ SOLUTION_FIELD : " PVTSSF_lADOCxeiOM4BR2KZzg_jXuY"
27+ PRIORITY_FIELD : " PVTSSF_lADOCxeiOM4BR2KZzg_jXvs"
28+ CATEGORY_FIELD : " PVTSSF_lADOCxeiOM4BR2KZzg_jXxA"
29+ steps :
30+ - name : Get project item ID
31+ id : find-item
32+ run : |
33+ ITEM_ID=$(gh project item-list 3 --owner AzureLocal --format json --limit 200 \
34+ | jq -r --arg url "${{ github.event.issue.html_url }}" \
35+ '.items[] | select(.content.url == $url) | .id')
36+ echo "item_id=$ITEM_ID" >> "$GITHUB_OUTPUT"
37+
38+ - name : Set Solution field
39+ if : steps.find-item.outputs.item_id != ''
40+ run : |
41+ ITEM_ID="${{ steps.find-item.outputs.item_id }}"
42+ LABELS='${{ toJson(github.event.issue.labels.*.name) }}'
43+ OPTION_ID=""
44+ if echo "$LABELS" | grep -q '"solution/sofs"'; then
45+ OPTION_ID="441d7b73"
46+ elif echo "$LABELS" | grep -q '"solution/avd"'; then
47+ OPTION_ID="88c2cad1"
48+ elif echo "$LABELS" | grep -q '"solution/loadtools"'; then
49+ OPTION_ID="e681af20"
50+ elif echo "$LABELS" | grep -q '"solution/vmconvert"'; then
51+ OPTION_ID="24cfc8b7"
52+ elif echo "$LABELS" | grep -q '"solution/docs-site"'; then
53+ OPTION_ID="409662e1"
54+ elif echo "$LABELS" | grep -q '"solution/workspace"'; then
55+ OPTION_ID="65042935"
56+ elif echo "$LABELS" | grep -q '"solution/toolkit"'; then
57+ OPTION_ID="5a5921eb"
58+ elif echo "$LABELS" | grep -q '"solution/aks"'; then
59+ OPTION_ID="b982b3f9"
60+ elif echo "$LABELS" | grep -q '"solution/sql-ha"'; then
61+ OPTION_ID="4b317a86"
62+ elif echo "$LABELS" | grep -q '"solution/iot"'; then
63+ OPTION_ID="a8348e7b"
64+ elif echo "$LABELS" | grep -q '"solution/vmware-migration"'; then
65+ OPTION_ID="38fc53af"
66+ elif echo "$LABELS" | grep -q '"solution/monitoring"'; then
67+ OPTION_ID="293a0462"
68+ elif echo "$LABELS" | grep -q '"solution/bcdr"'; then
69+ OPTION_ID="7b2cf8f7"
70+ elif echo "$LABELS" | grep -q '"solution/cost"'; then
71+ OPTION_ID="4b39412e"
72+ elif echo "$LABELS" | grep -q '"solution/governance"'; then
73+ OPTION_ID="2534a020"
74+ elif echo "$LABELS" | grep -q '"solution/hydration"'; then
75+ OPTION_ID="6aef96cb"
76+ elif echo "$LABELS" | grep -q '"solution/custom-images"'; then
77+ OPTION_ID="2d4dca21"
78+ elif echo "$LABELS" | grep -q '"solution/app-services"'; then
79+ OPTION_ID="9b88133a"
80+ elif echo "$LABELS" | grep -q '"solution/sql-mi"'; then
81+ OPTION_ID="7fce49ac"
82+ elif echo "$LABELS" | grep -q '"solution/ml-ai"'; then
83+ OPTION_ID="23c5f7a9"
84+ elif echo "$LABELS" | grep -q '"solution/vms"'; then
85+ OPTION_ID="61b679bd"
86+ elif echo "$LABELS" | grep -q '"solution/disconnected"'; then
87+ OPTION_ID="5633c889"
88+ fi
89+ if [ -n "$OPTION_ID" ]; then
90+ gh project item-edit --project-id "$PROJECT_ID" --id "$ITEM_ID" \
91+ --field-id "$SOLUTION_FIELD" --single-select-option-id "$OPTION_ID"
92+ fi
93+
94+ - name : Set Priority field
95+ if : steps.find-item.outputs.item_id != ''
96+ run : |
97+ ITEM_ID="${{ steps.find-item.outputs.item_id }}"
98+ LABELS='${{ toJson(github.event.issue.labels.*.name) }}'
99+ OPTION_ID=""
100+ if echo "$LABELS" | grep -q '"priority/critical"'; then
101+ OPTION_ID="74334e8d"
102+ elif echo "$LABELS" | grep -q '"priority/high"'; then
103+ OPTION_ID="2e3ede9d"
104+ elif echo "$LABELS" | grep -q '"priority/medium"'; then
105+ OPTION_ID="7709e85d"
106+ elif echo "$LABELS" | grep -q '"priority/low"'; then
107+ OPTION_ID="2182b5f9"
108+ fi
109+ if [ -n "$OPTION_ID" ]; then
110+ gh project item-edit --project-id "$PROJECT_ID" --id "$ITEM_ID" \
111+ --field-id "$PRIORITY_FIELD" --single-select-option-id "$OPTION_ID"
112+ fi
113+
114+ - name : Set Category field
115+ if : steps.find-item.outputs.item_id != ''
116+ run : |
117+ ITEM_ID="${{ steps.find-item.outputs.item_id }}"
118+ LABELS='${{ toJson(github.event.issue.labels.*.name) }}'
119+ OPTION_ID=""
120+ if echo "$LABELS" | grep -q '"type/feature"'; then
121+ OPTION_ID="7a4fa8ea"
122+ elif echo "$LABELS" | grep -q '"type/bug"'; then
123+ OPTION_ID="206e624a"
124+ elif echo "$LABELS" | grep -q '"type/docs"'; then
125+ OPTION_ID="355ce6c1"
126+ elif echo "$LABELS" | grep -q '"type/infra"'; then
127+ OPTION_ID="05996f93"
128+ elif echo "$LABELS" | grep -q '"type/refactor"'; then
129+ OPTION_ID="7f5509ab"
130+ elif echo "$LABELS" | grep -q '"type/security"'; then
131+ OPTION_ID="d2af4749"
132+ fi
133+ if [ -n "$OPTION_ID" ]; then
134+ gh project item-edit --project-id "$PROJECT_ID" --id "$ITEM_ID" \
135+ --field-id "$CATEGORY_FIELD" --single-select-option-id "$OPTION_ID"
136+ fi
0 commit comments