-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathupdate-issue-remaining-days.yml
More file actions
61 lines (48 loc) · 2.1 KB
/
update-issue-remaining-days.yml
File metadata and controls
61 lines (48 loc) · 2.1 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
name: Auto-Set Remaining Days to 0 on Issue Closed
on:
issues:
types: [closed]
jobs:
update_remaining_days:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Debug - List project items linked to this issue
env:
GH_TOKEN: ${{ secrets.UPDATE_PROJECT_V2_PAT }}
run: |
echo "🔍 Listing all project items linked to issue ${{ github.event.issue.number }}..."
gh issue view ${{ github.event.issue.number }} \
--repo ${{ github.repository }} \
--json projectItems \
| jq .
- name: Set Remaining Days to 0 if issue is in Project 183
env:
GH_TOKEN: ${{ secrets.UPDATE_PROJECT_V2_PAT }}
run: |
echo "🔍 Checking if issue ${{ github.event.issue.number }} belongs to Project 183..."
# Get the project item ID from projectItems
ITEM_ID=$(gh issue view ${{ github.event.issue.number }} \
--repo ${{ github.repository }} \
--json projectItems \
| jq -r '.projectItems[] | select(.project.number==183) | .id')
if [ -z "$ITEM_ID" ]; then
echo "ℹ️ Issue is not in Project 183. Nothing to update."
exit 0
fi
echo "✅ Found Project Item ID in Project 183: $ITEM_ID"
# Find the field ID for "Remaining Days"
FIELD_ID=$(gh project field-list --owner microsoft --number 183 --format json \
| jq -r '.[] | select(.name=="Remaining Days") | .id')
if [ -z "$FIELD_ID" ]; then
echo "❌ No field named 'Remaining Days' found in Project 183."
exit 1
fi
echo "✅ Found Field ID for Remaining Days: $FIELD_ID"
# Update the field value to 0
gh project item-update --owner microsoft --number 183 \
--id "$ITEM_ID" --field-id "$FIELD_ID" --value "0"
echo "🎉 Successfully set Remaining Days = 0 for issue ${{ github.event.issue.number }}"