Skip to content

Commit 229ca8f

Browse files
authored
Merge branch 'ArmDeveloperEcosystem:main' into ollama_image_update
2 parents c5d7ff8 + ef26fec commit 229ca8f

File tree

1 file changed

+126
-26
lines changed

1 file changed

+126
-26
lines changed
Lines changed: 126 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,156 @@
1-
name: Update Arm Learning Path Roadmap Project Dates
1+
name: Update Project Custom Fields
22

33
on:
4-
issues:
4+
pull_request:
55
types:
6-
- edited # Triggered when an issue is edited
6+
- labeled
7+
- unlabeled
78

89
jobs:
9-
update-dates:
10+
update-fields:
1011
runs-on: ubuntu-latest
12+
1113
steps:
12-
- name: Update Start Date
13-
if: |
14-
contains(github.event.changes.fields['Status'].from, 'To Do') &&
15-
contains(github.event.changes.fields['Status'].to, 'In Progress')
14+
# Step 1: Set "Start Date" when PR is labeled "awaiting_tech_review"
15+
- name: Set Start Date
16+
if: contains(github.event.label.name, 'awaiting_tech_review') # Trigger only if the label is "awaiting_tech_review"
1617
env:
1718
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
PROJECT_NUMBER: 4 # Replace with your project number
20+
START_DATE_FIELD_NAME: "Start Date"
1821
run: |
19-
gh api graphql -f query='
20-
mutation($id: ID!, $date: String!) {
22+
# GraphQL Query to find the project item ID and "Start Date" field ID
23+
QUERY=$(cat <<EOF
24+
query {
25+
organization(login: "ArmDeveloperEcosystem") {
26+
projectV2(number: $PROJECT_NUMBER) {
27+
id
28+
items(first: 100) {
29+
nodes {
30+
id
31+
content {
32+
... on PullRequest {
33+
id
34+
url
35+
}
36+
}
37+
}
38+
}
39+
fields(first: 20) {
40+
nodes {
41+
id
42+
name
43+
}
44+
}
45+
}
46+
}
47+
}
48+
EOF
49+
)
50+
51+
# Execute the query
52+
RESPONSE=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
53+
-X POST -d "{\"query\": \"$QUERY\"}" \
54+
https://api.github.com/graphql)
55+
56+
# Extract the project item ID and field ID for "Start Date"
57+
PROJECT_ITEM_ID=$(echo $RESPONSE | jq -r \
58+
".data.organization.projectV2.items.nodes[] | select(.content.url == \"${{ github.event.issue.html_url }}\") | .id")
59+
START_DATE_FIELD_ID=$(echo $RESPONSE | jq -r \
60+
".data.organization.projectV2.fields.nodes[] | select(.name == \"$START_DATE_FIELD_NAME\") | .id")
61+
62+
# Update "Start Date" field with the current date
63+
CURRENT_DATE=$(date +%Y-%m-%d)
64+
UPDATE_MUTATION=$(cat <<EOF
65+
mutation {
2166
updateProjectV2ItemFieldValue(
2267
input: {
23-
projectId: "PVT_kwDOBVR2-M4A2QVf", # Replace with your actual project ID
24-
itemId: $id,
25-
fieldId: "PVTF_lADOBVR2-M4A2QVfzgrvSF4", # Replace with your Start Date field ID
26-
value: $date
68+
projectId: "${{ secrets.PROJECT_ID }}"
69+
itemId: "$PROJECT_ITEM_ID"
70+
fieldId: "$START_DATE_FIELD_ID"
71+
value: "$CURRENT_DATE"
2772
}
2873
) {
2974
projectV2Item {
3075
id
3176
}
3277
}
33-
}' -f id="${{ github.event.issue.node_id }}" -f date="$(date -u +%Y-%m-%d)"
78+
}
79+
EOF
80+
)
81+
82+
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
83+
-X POST -d "{\"query\": \"$UPDATE_MUTATION\"}" \
84+
https://api.github.com/graphql
3485
35-
- name: Update Publish Date
36-
if: |
37-
contains(github.event.changes.fields['Status'].from, 'In Progress') &&
38-
contains(github.event.changes.fields['Status'].to, 'Done')
86+
# Step 2: Set "Publish Date" when PR is labeled "Done"
87+
- name: Set Publish Date
88+
if: contains(github.event.label.name, 'Done') # Trigger only if the label is "Done"
3989
env:
4090
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
PROJECT_NUMBER: 4 # Replace with your project number
92+
PUBLISH_DATE_FIELD_NAME: "Publish Date"
4193
run: |
42-
gh api graphql -f query='
43-
mutation($id: ID!, $date: String!) {
94+
# GraphQL Query to find the project item ID and "Publish Date" field ID
95+
QUERY=$(cat <<EOF
96+
query {
97+
organization(login: "ArmDeveloperEcosystem") {
98+
projectV2(number: $PROJECT_NUMBER) {
99+
id
100+
items(first: 100) {
101+
nodes {
102+
id
103+
content {
104+
... on PullRequest {
105+
id
106+
url
107+
}
108+
}
109+
}
110+
}
111+
fields(first: 20) {
112+
nodes {
113+
id
114+
name
115+
}
116+
}
117+
}
118+
}
119+
}
120+
EOF
121+
)
122+
123+
# Execute the query
124+
RESPONSE=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
125+
-X POST -d "{\"query\": \"$QUERY\"}" \
126+
https://api.github.com/graphql)
127+
128+
# Extract the project item ID and field ID for "Publish Date"
129+
PROJECT_ITEM_ID=$(echo $RESPONSE | jq -r \
130+
".data.organization.projectV2.items.nodes[] | select(.content.url == \"${{ github.event.issue.html_url }}\") | .id")
131+
PUBLISH_DATE_FIELD_ID=$(echo $RESPONSE | jq -r \
132+
".data.organization.projectV2.fields.nodes[] | select(.name == \"$PUBLISH_DATE_FIELD_NAME\") | .id")
133+
134+
# Update "Publish Date" field with the current date
135+
CURRENT_DATE=$(date +%Y-%m-%d)
136+
UPDATE_MUTATION=$(cat <<EOF
137+
mutation {
44138
updateProjectV2ItemFieldValue(
45139
input: {
46-
projectId: "PVT_kwDOBVR2-M4A2QVf", # Replace with your actual project ID
47-
itemId: $id,
48-
fieldId: "PVTF_lADOBVR2-M4A2QVfzgrvSMA", # Replace with your Publish Date (end date) field ID
49-
value: $date
140+
projectId: "${{ secrets.PROJECT_ID }}"
141+
itemId: "$PROJECT_ITEM_ID"
142+
fieldId: "$PUBLISH_DATE_FIELD_ID"
143+
value: "$CURRENT_DATE"
50144
}
51145
) {
52146
projectV2Item {
53147
id
54148
}
55149
}
56-
}' -f id="${{ github.event.issue.node_id }}" -f date="$(date -u +%Y-%m-%d)"
150+
}
151+
EOF
152+
)
153+
154+
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
155+
-X POST -d "{\"query\": \"$UPDATE_MUTATION\"}" \
156+
https://api.github.com/graphql

0 commit comments

Comments
 (0)