Skip to content

Commit f28975a

Browse files
fix: use action output for item ID, remove find-item step
- Use steps.add.outputs.itemId directly instead of fragile item-list query - Remove find-item step (was timing-sensitive and broke for projects with >200 items) - Remove per-step if conditions referencing find-item - Use job-level condition on add-to-project.result to prevent silent failures - Solution option IDs were already correct in this repo
1 parent 14f4942 commit f28975a

1 file changed

Lines changed: 4 additions & 15 deletions

File tree

.github/workflows/add-to-project.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
add-to-project:
1111
runs-on: ubuntu-latest
12+
outputs:
13+
item_id: ${{ steps.add.outputs.itemId }}
1214
steps:
1315
- uses: actions/add-to-project@v1.0.2
1416
id: add
@@ -19,26 +21,17 @@ jobs:
1921
set-fields:
2022
needs: add-to-project
2123
runs-on: ubuntu-latest
22-
if: always() && github.event_name == 'issues'
24+
if: github.event_name == 'issues' && needs.add-to-project.result == 'success' && needs.add-to-project.outputs.item_id != ''
2325
env:
2426
GH_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }}
2527
PROJECT_ID: "PVT_kwDOCxeiOM4BR2KZ"
2628
SOLUTION_FIELD: "PVTSSF_lADOCxeiOM4BR2KZzg_jXuY"
2729
PRIORITY_FIELD: "PVTSSF_lADOCxeiOM4BR2KZzg_jXvs"
2830
CATEGORY_FIELD: "PVTSSF_lADOCxeiOM4BR2KZzg_jXxA"
31+
ITEM_ID: ${{ needs.add-to-project.outputs.item_id }}
2932
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-
3833
- name: Set Solution field
39-
if: steps.find-item.outputs.item_id != ''
4034
run: |
41-
ITEM_ID="${{ steps.find-item.outputs.item_id }}"
4235
LABELS='${{ toJson(github.event.issue.labels.*.name) }}'
4336
OPTION_ID=""
4437
if echo "$LABELS" | grep -q '"solution/sofs"'; then
@@ -92,9 +85,7 @@ jobs:
9285
fi
9386
9487
- name: Set Priority field
95-
if: steps.find-item.outputs.item_id != ''
9688
run: |
97-
ITEM_ID="${{ steps.find-item.outputs.item_id }}"
9889
LABELS='${{ toJson(github.event.issue.labels.*.name) }}'
9990
OPTION_ID=""
10091
if echo "$LABELS" | grep -q '"priority/critical"'; then
@@ -112,9 +103,7 @@ jobs:
112103
fi
113104
114105
- name: Set Category field
115-
if: steps.find-item.outputs.item_id != ''
116106
run: |
117-
ITEM_ID="${{ steps.find-item.outputs.item_id }}"
118107
LABELS='${{ toJson(github.event.issue.labels.*.name) }}'
119108
OPTION_ID=""
120109
if echo "$LABELS" | grep -q '"type/feature"'; then

0 commit comments

Comments
 (0)