From c46ba5b47832e04d4d6fba3cf32b53a370c459a3 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 08:44:43 +0100 Subject: [PATCH 01/21] refactor: added merge check --- .../sync-labels-with-project-status.yml | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 .github/workflows/sync-labels-with-project-status.yml diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml new file mode 100644 index 0000000..92c9e11 --- /dev/null +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -0,0 +1,131 @@ +name: Sync PR Labels with GitHub Project Status + +on: + schedule: + - cron: '*/10 * * * *' # Runs every 10 minutes + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + +jobs: + check_project_status: + runs-on: ubuntu-latest + steps: + - name: Get PR Project Item ID + id: get_project_item + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + OWNER=${{ github.repository_owner }} + REPO=${{ github.event.repository.name }} + + echo "Fetching Project ID..." + + PROJECT_ID=$(gh api graphql -f query=' + query { + user(login: "'"$OWNER"'") { + projectV2(number: YOUR_PROJECT_NUMBER) { + id + } + } + }' --jq '.data.user.projectV2.id') + + echo "Project ID: $PROJECT_ID" + echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_ENV + + echo "Fetching Project Item ID..." + + ITEM_ID=$(gh api graphql -f query=' + query { + repository(owner: "'"$OWNER"'", name: "'"$REPO"'") { + pullRequest(number: '$PR_NUMBER') { + projectItems(first: 5) { + nodes { + id + project { + id + } + } + } + } + } + }' --jq '.data.repository.pullRequest.projectItems.nodes[0].id') + + echo "Project Item ID: $ITEM_ID" + echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV + + - name: Get PR Project Status + id: get_status + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PROJECT_ITEM_ID=${{ env.ITEM_ID }} + + STATUS=$(gh api graphql -f query=' + query { + node(id: "'"$PROJECT_ITEM_ID"'") { + ... on ProjectV2Item { + fieldValues(first: 10) { + nodes { + field { + ... on ProjectV2FieldCommon { + name + } + } + value + } + } + } + } + }' --jq '.data.node.fieldValues.nodes[] | select(.field.name=="Status") | .value') + + echo "Project Status: $STATUS" + echo "STATUS=$STATUS" >> $GITHUB_ENV + + - name: Apply or Remove "Do Not Merge" Label + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + REPO=${{ github.repository }} + LABEL="Do Not Merge" + + if [[ "$STATUS" == "ready for release" || "$STATUS" == "In Progress" ]]; then + echo "Adding '$LABEL' label..." + gh issue edit $PR_NUMBER --repo "$REPO" --add-label "$LABEL" + else + echo "Removing '$LABEL' label..." + gh issue edit $PR_NUMBER --repo "$REPO" --remove-label "$LABEL" + fi + + - name: Comment on PR if Blocked + if: env.STATUS == 'ready for release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + REPO=${{ github.repository }} + + COMMENT="⚠️ This PR is currently in a 'ready for release' state in GitHub Projects and cannot be merged. Please remove the 'Do Not Merge' label to proceed." + + gh pr comment $PR_NUMBER --repo "$REPO" --body "$COMMENT" + + block_merge_if_label_exists: + runs-on: ubuntu-latest + needs: check_project_status + steps: + - name: Check for "Do Not Merge" Label + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + REPO=${{ github.repository }} + + LABELS=$(gh issue view $PR_NUMBER --repo "$REPO" --json labels --jq '.labels[].name') + + if echo "$LABELS" | grep -q "Do Not Merge"; then + echo "❌ Merge is blocked due to 'Do Not Merge' label!" + exit 1 + fi + + echo "✅ Merge allowed." From be2dd5ec07258eb427fee37ff765e6ad686e8557 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 08:48:12 +0100 Subject: [PATCH 02/21] Update sync-labels-with-project-status.yml --- .../sync-labels-with-project-status.yml | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 92c9e11..1973849 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -14,25 +14,12 @@ jobs: id: get_project_item env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }} # Use your predefined Project ID run: | PR_NUMBER=${{ github.event.pull_request.number }} OWNER=${{ github.repository_owner }} REPO=${{ github.event.repository.name }} - echo "Fetching Project ID..." - - PROJECT_ID=$(gh api graphql -f query=' - query { - user(login: "'"$OWNER"'") { - projectV2(number: YOUR_PROJECT_NUMBER) { - id - } - } - }' --jq '.data.user.projectV2.id') - - echo "Project ID: $PROJECT_ID" - echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_ENV - echo "Fetching Project Item ID..." ITEM_ID=$(gh api graphql -f query=' @@ -49,7 +36,7 @@ jobs: } } } - }' --jq '.data.repository.pullRequest.projectItems.nodes[0].id') + }' --jq '.data.repository.pullRequest.projectItems.nodes[] | select(.project.id=="'"$DEV_PROJECT_ID"'") | .id') echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV @@ -90,7 +77,7 @@ jobs: REPO=${{ github.repository }} LABEL="Do Not Merge" - if [[ "$STATUS" == "ready for release" || "$STATUS" == "In Progress" ]]; then + if [[ "$STATUS" == "Blocked" || "$STATUS" == "In Progress" ]]; then echo "Adding '$LABEL' label..." gh issue edit $PR_NUMBER --repo "$REPO" --add-label "$LABEL" else @@ -99,14 +86,14 @@ jobs: fi - name: Comment on PR if Blocked - if: env.STATUS == 'ready for release' + if: env.STATUS == 'Blocked' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PR_NUMBER=${{ github.event.pull_request.number }} REPO=${{ github.repository }} - COMMENT="⚠️ This PR is currently in a 'ready for release' state in GitHub Projects and cannot be merged. Please remove the 'Do Not Merge' label to proceed." + COMMENT="⚠️ This PR is currently in a 'Blocked' state in GitHub Projects and cannot be merged." gh pr comment $PR_NUMBER --repo "$REPO" --body "$COMMENT" From 8dd0abd4e657711013d3791a1f6952d348f6cb5c Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 08:49:51 +0100 Subject: [PATCH 03/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 1973849..5fa0b2d 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -77,7 +77,7 @@ jobs: REPO=${{ github.repository }} LABEL="Do Not Merge" - if [[ "$STATUS" == "Blocked" || "$STATUS" == "In Progress" ]]; then + if [[ "$STATUS" == "ready for release" ]]; then echo "Adding '$LABEL' label..." gh issue edit $PR_NUMBER --repo "$REPO" --add-label "$LABEL" else @@ -85,15 +85,15 @@ jobs: gh issue edit $PR_NUMBER --repo "$REPO" --remove-label "$LABEL" fi - - name: Comment on PR if Blocked - if: env.STATUS == 'Blocked' + - name: Comment on PR if "Ready for Release" + if: env.STATUS == 'ready for release' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PR_NUMBER=${{ github.event.pull_request.number }} REPO=${{ github.repository }} - COMMENT="⚠️ This PR is currently in a 'Blocked' state in GitHub Projects and cannot be merged." + COMMENT="⚠️ This PR is currently in a 'ready for release' state in GitHub Projects and cannot be merged. Please remove the 'Do Not Merge' label to proceed." gh pr comment $PR_NUMBER --repo "$REPO" --body "$COMMENT" From ccf60b47192ccfc18f3e9820017256ff1e1c5d51 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 08:57:30 +0100 Subject: [PATCH 04/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 5fa0b2d..0083c82 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -48,6 +48,8 @@ jobs: run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} + echo "Fetching project status..." + STATUS=$(gh api graphql -f query=' query { node(id: "'"$PROJECT_ITEM_ID"'") { @@ -59,12 +61,14 @@ jobs: name } } - value + ... on ProjectV2ItemFieldSingleSelectValue { + name + } } } } } - }' --jq '.data.node.fieldValues.nodes[] | select(.field.name=="Status") | .value') + }' --jq '.data.node.fieldValues.nodes[] | select(.field.name=="Status") | .name') echo "Project Status: $STATUS" echo "STATUS=$STATUS" >> $GITHUB_ENV From 96d1559b4e35e88b13cfb5318f319a070c6061be Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:00:12 +0100 Subject: [PATCH 05/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 0083c82..5467a40 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -14,7 +14,7 @@ jobs: id: get_project_item env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }} # Use your predefined Project ID + DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }} run: | PR_NUMBER=${{ github.event.pull_request.number }} OWNER=${{ github.repository_owner }} @@ -61,6 +61,7 @@ jobs: name } } + __typename ... on ProjectV2ItemFieldSingleSelectValue { name } @@ -68,7 +69,7 @@ jobs: } } } - }' --jq '.data.node.fieldValues.nodes[] | select(.field.name=="Status") | .name') + }' --jq '.data.node.fieldValues.nodes[] | select(.field.name=="Status" and .__typename=="ProjectV2ItemFieldSingleSelectValue") | .name') echo "Project Status: $STATUS" echo "STATUS=$STATUS" >> $GITHUB_ENV From cb671801e464c4ddc25d7a44f6e133209be27f6d Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:01:33 +0100 Subject: [PATCH 06/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 5467a40..ad18dac 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -69,7 +69,7 @@ jobs: } } } - }' --jq '.data.node.fieldValues.nodes[] | select(.field.name=="Status" and .__typename=="ProjectV2ItemFieldSingleSelectValue") | .name') + }' --jq '.data.node.fieldValues.nodes[] | select(.field.name=="Status") | select(.__typename=="ProjectV2ItemFieldSingleSelectValue") | .name') echo "Project Status: $STATUS" echo "STATUS=$STATUS" >> $GITHUB_ENV From 24c6659e8c5ced43f70b41d82270c6985e7f70b3 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:03:39 +0100 Subject: [PATCH 07/21] Create debug.yml --- .github/workflows/debug.yml | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/debug.yml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 0000000..6d91570 --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,39 @@ +- name: Debug: Get PR Project Status + id: get_status_debug + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PROJECT_ITEM_ID=${{ env.ITEM_ID }} + + echo "Fetching raw project status data..." + + RAW_RESPONSE=$(gh api graphql -f query=' + query { + node(id: "'"$PROJECT_ITEM_ID"'") { + ... on ProjectV2Item { + fieldValues(first: 10) { + nodes { + __typename + field { + ... on ProjectV2FieldCommon { + name + } + } + ... on ProjectV2ItemFieldSingleSelectValue { + name + } + ... on ProjectV2ItemFieldTextValue { + text + } + ... on ProjectV2ItemFieldNumberValue { + number + } + } + } + } + } + }') + + echo "Full API Response: $RAW_RESPONSE" + + echo "$RAW_RESPONSE" > project_debug.json From 165dc58f6dc4f7582887fc47f1d5fb9802edd81e Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:05:22 +0100 Subject: [PATCH 08/21] Delete .github/workflows/debug.yml --- .github/workflows/debug.yml | 39 ------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 .github/workflows/debug.yml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml deleted file mode 100644 index 6d91570..0000000 --- a/.github/workflows/debug.yml +++ /dev/null @@ -1,39 +0,0 @@ -- name: Debug: Get PR Project Status - id: get_status_debug - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - PROJECT_ITEM_ID=${{ env.ITEM_ID }} - - echo "Fetching raw project status data..." - - RAW_RESPONSE=$(gh api graphql -f query=' - query { - node(id: "'"$PROJECT_ITEM_ID"'") { - ... on ProjectV2Item { - fieldValues(first: 10) { - nodes { - __typename - field { - ... on ProjectV2FieldCommon { - name - } - } - ... on ProjectV2ItemFieldSingleSelectValue { - name - } - ... on ProjectV2ItemFieldTextValue { - text - } - ... on ProjectV2ItemFieldNumberValue { - number - } - } - } - } - } - }') - - echo "Full API Response: $RAW_RESPONSE" - - echo "$RAW_RESPONSE" > project_debug.json From 6b113dfaf011a1cbabee6325028e63b4ffa79354 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:06:06 +0100 Subject: [PATCH 09/21] Update sync-labels-with-project-status.yml --- .../sync-labels-with-project-status.yml | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index ad18dac..46d543d 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -41,38 +41,45 @@ jobs: echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - - name: Get PR Project Status - id: get_status + - name: Debug: Get PR Project Status + id: get_status_debug env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} - - echo "Fetching project status..." + + echo "Fetching raw project status data..." - STATUS=$(gh api graphql -f query=' + RAW_RESPONSE=$(gh api graphql -f query=' query { node(id: "'"$PROJECT_ITEM_ID"'") { ... on ProjectV2Item { fieldValues(first: 10) { nodes { + __typename field { ... on ProjectV2FieldCommon { name } } - __typename ... on ProjectV2ItemFieldSingleSelectValue { name } + ... on ProjectV2ItemFieldTextValue { + text + } + ... on ProjectV2ItemFieldNumberValue { + number + } } } } } - }' --jq '.data.node.fieldValues.nodes[] | select(.field.name=="Status") | select(.__typename=="ProjectV2ItemFieldSingleSelectValue") | .name') - - echo "Project Status: $STATUS" - echo "STATUS=$STATUS" >> $GITHUB_ENV + }') + + echo "Full API Response: $RAW_RESPONSE" + + echo "$RAW_RESPONSE" > project_debug.json - name: Apply or Remove "Do Not Merge" Label env: From 0fca7cb825023db2a127d6f83d175ee3613c8737 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:07:09 +0100 Subject: [PATCH 10/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 46d543d..3a80352 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -47,7 +47,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} - + echo "Fetching raw project status data..." RAW_RESPONSE=$(gh api graphql -f query=' @@ -76,11 +76,11 @@ jobs: } } }') - + echo "Full API Response: $RAW_RESPONSE" echo "$RAW_RESPONSE" > project_debug.json - + - name: Apply or Remove "Do Not Merge" Label env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0a80377adf227fea9614f3374aa455306b6cfa8a Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:08:48 +0100 Subject: [PATCH 11/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 3a80352..61c2259 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -41,7 +41,7 @@ jobs: echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - - name: Debug: Get PR Project Status + - name: Debug – Get PR Project Status id: get_status_debug env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d4fb4ce2e49cf4621fc173b48fedab5614e82013 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:10:32 +0100 Subject: [PATCH 12/21] Update sync-labels-with-project-status.yml --- .../sync-labels-with-project-status.yml | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 61c2259..2a17292 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -41,16 +41,16 @@ jobs: echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - - name: Debug – Get PR Project Status - id: get_status_debug + - name: Get PR Project Status + id: get_status env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} - - echo "Fetching raw project status data..." - - RAW_RESPONSE=$(gh api graphql -f query=' + + echo "Fetching project status..." + + STATUS=$(gh api graphql -f query=' query { node(id: "'"$PROJECT_ITEM_ID"'") { ... on ProjectV2Item { @@ -65,21 +65,17 @@ jobs: ... on ProjectV2ItemFieldSingleSelectValue { name } - ... on ProjectV2ItemFieldTextValue { - text - } - ... on ProjectV2ItemFieldNumberValue { - number - } } } } } - }') - - echo "Full API Response: $RAW_RESPONSE" + }' --jq ' + .data.node.fieldValues.nodes[] + | select(.field.name == "Status" and .__typename == "ProjectV2ItemFieldSingleSelectValue") + | .name') - echo "$RAW_RESPONSE" > project_debug.json + echo "Project Status: $STATUS" + echo "STATUS=$STATUS" >> $GITHUB_ENV - name: Apply or Remove "Do Not Merge" Label env: From 05099f53489cbec66620c404030759c78df706cf Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:11:49 +0100 Subject: [PATCH 13/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 2a17292..8ae5507 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -47,7 +47,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} - + echo "Fetching project status..." STATUS=$(gh api graphql -f query=' From 5fb81bebb4d75866397708bc28ce3a20ad6b7686 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:12:44 +0100 Subject: [PATCH 14/21] Update sync-labels-with-project-status.yml --- .../sync-labels-with-project-status.yml | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 8ae5507..a2e9739 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -41,16 +41,16 @@ jobs: echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - - name: Get PR Project Status - id: get_status + - name: Debug – Get PR Project Status + id: get_status_debug env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} - - echo "Fetching project status..." - STATUS=$(gh api graphql -f query=' + echo "Fetching raw project status data..." + + gh api graphql -f query=' query { node(id: "'"$PROJECT_ITEM_ID"'") { ... on ProjectV2Item { @@ -62,20 +62,11 @@ jobs: name } } - ... on ProjectV2ItemFieldSingleSelectValue { - name - } } } } } - }' --jq ' - .data.node.fieldValues.nodes[] - | select(.field.name == "Status" and .__typename == "ProjectV2ItemFieldSingleSelectValue") - | .name') - - echo "Project Status: $STATUS" - echo "STATUS=$STATUS" >> $GITHUB_ENV + }' - name: Apply or Remove "Do Not Merge" Label env: From e7dcbb3c189a285c5f85575c7f98e15d4d66b09b Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:14:06 +0100 Subject: [PATCH 15/21] Update sync-labels-with-project-status.yml --- .../sync-labels-with-project-status.yml | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index a2e9739..d68567f 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -41,16 +41,16 @@ jobs: echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - - name: Debug – Get PR Project Status - id: get_status_debug + - name: Get PR Project Status + id: get_status env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} - echo "Fetching raw project status data..." - - gh api graphql -f query=' + echo "Fetching project status..." + + STATUS=$(gh api graphql -f query=' query { node(id: "'"$PROJECT_ITEM_ID"'") { ... on ProjectV2Item { @@ -58,15 +58,26 @@ jobs: nodes { __typename field { - ... on ProjectV2FieldCommon { + __typename + ... on ProjectV2SingleSelectField { name } } + ... on ProjectV2ItemFieldSingleSelectValue { + name + } } } } } - }' + }' --jq ' + .data.node.fieldValues.nodes[] + | select(.field.__typename == "ProjectV2SingleSelectField" and .field.name == "Status") + | select(.__typename == "ProjectV2ItemFieldSingleSelectValue") + | .name') + + echo "Project Status: $STATUS" + echo "STATUS=$STATUS" >> $GITHUB_ENV - name: Apply or Remove "Do Not Merge" Label env: From d24c5b6dd08c689f6806d0e0278fb3b3bcf463cf Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:15:20 +0100 Subject: [PATCH 16/21] Update sync-labels-with-project-status.yml --- .../sync-labels-with-project-status.yml | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index d68567f..22adb63 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -41,16 +41,16 @@ jobs: echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - - name: Get PR Project Status - id: get_status + - name: Debug – Get PR Project Status (Raw Data) + id: debug_status env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} - echo "Fetching project status..." + echo "Fetching raw project status data..." - STATUS=$(gh api graphql -f query=' + RAW_RESPONSE=$(gh api graphql -f query=' query { node(id: "'"$PROJECT_ITEM_ID"'") { ... on ProjectV2Item { @@ -59,25 +59,14 @@ jobs: __typename field { __typename - ... on ProjectV2SingleSelectField { - name - } - } - ... on ProjectV2ItemFieldSingleSelectValue { - name } } } } } - }' --jq ' - .data.node.fieldValues.nodes[] - | select(.field.__typename == "ProjectV2SingleSelectField" and .field.name == "Status") - | select(.__typename == "ProjectV2ItemFieldSingleSelectValue") - | .name') + }') - echo "Project Status: $STATUS" - echo "STATUS=$STATUS" >> $GITHUB_ENV + echo "Raw Response: $RAW_RESPONSE" - name: Apply or Remove "Do Not Merge" Label env: From ab58dcc936675debe62d6dfb6be0971913b18376 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:16:49 +0100 Subject: [PATCH 17/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 22adb63..322ca06 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -41,7 +41,7 @@ jobs: echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - - name: Debug – Get PR Project Status (Raw Data) + - name: Debug – Get PR Project Status – raw data id: debug_status env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a64a17940a04eb80ab7ccc64e378cd269e2e6f04 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:18:12 +0100 Subject: [PATCH 18/21] Update sync-labels-with-project-status.yml --- .github/workflows/sync-labels-with-project-status.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 322ca06..5f2773e 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -41,14 +41,14 @@ jobs: echo "Project Item ID: $ITEM_ID" echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - - name: Debug – Get PR Project Status – raw data + - name: Debug – Get PR Project Status – Only __typename id: debug_status env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PROJECT_ITEM_ID=${{ env.ITEM_ID }} - echo "Fetching raw project status data..." + echo "Fetching project status type information..." RAW_RESPONSE=$(gh api graphql -f query=' query { @@ -57,16 +57,13 @@ jobs: fieldValues(first: 10) { nodes { __typename - field { - __typename - } } } } } }') - echo "Raw Response: $RAW_RESPONSE" + echo "Raw Type Response: $RAW_RESPONSE" - name: Apply or Remove "Do Not Merge" Label env: From c1d6d962c83eb1a24687a1b94a6bb822e2962189 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:19:38 +0100 Subject: [PATCH 19/21] Update sync-labels-with-project-status.yml --- .../workflows/sync-labels-with-project-status.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 5f2773e..144b099 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -19,9 +19,9 @@ jobs: PR_NUMBER=${{ github.event.pull_request.number }} OWNER=${{ github.repository_owner }} REPO=${{ github.event.repository.name }} - + echo "Fetching Project Item ID..." - + ITEM_ID=$(gh api graphql -f query=' query { repository(owner: "'"$OWNER"'", name: "'"$REPO"'") { @@ -37,8 +37,14 @@ jobs: } } }' --jq '.data.repository.pullRequest.projectItems.nodes[] | select(.project.id=="'"$DEV_PROJECT_ID"'") | .id') - - echo "Project Item ID: $ITEM_ID" + + echo "Fetched ITEM_ID: $ITEM_ID" + + if [[ -z "$ITEM_ID" ]]; then + echo "❌ ERROR: No Project Item ID found! Please check the project association." + exit 1 + fi + echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV - name: Debug – Get PR Project Status – Only __typename From 1d6438dc78a3f025d854041746f92926ae841f9a Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:22:14 +0100 Subject: [PATCH 20/21] Update sync-labels-with-project-status.yml --- .../sync-labels-with-project-status.yml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 144b099..25a5f9d 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -10,6 +10,35 @@ jobs: check_project_status: runs-on: ubuntu-latest steps: + - name: Debug – Fetch PR Project Items + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + OWNER=${{ github.repository_owner }} + REPO=${{ github.event.repository.name }} + + echo "Fetching raw project item data for PR #$PR_NUMBER..." + + RAW_RESPONSE=$(gh api graphql -f query=' + query { + repository(owner: "'"$OWNER"'", name: "'"$REPO"'") { + pullRequest(number: '$PR_NUMBER') { + projectItems(first: 5) { + nodes { + id + project { + id + } + } + } + } + } + }') + + echo "Raw GraphQL Response: $RAW_RESPONSE" + - name: Get PR Project Item ID id: get_project_item env: From b50d6a4d793bd3305fd239ecfff300071becbcee Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:23:00 +0100 Subject: [PATCH 21/21] Update sync-labels-with-project-status.yml --- .../sync-labels-with-project-status.yml | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/sync-labels-with-project-status.yml b/.github/workflows/sync-labels-with-project-status.yml index 25a5f9d..baf6a8b 100644 --- a/.github/workflows/sync-labels-with-project-status.yml +++ b/.github/workflows/sync-labels-with-project-status.yml @@ -10,34 +10,34 @@ jobs: check_project_status: runs-on: ubuntu-latest steps: - - name: Debug – Fetch PR Project Items - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }} - run: | - PR_NUMBER=${{ github.event.pull_request.number }} - OWNER=${{ github.repository_owner }} - REPO=${{ github.event.repository.name }} - - echo "Fetching raw project item data for PR #$PR_NUMBER..." - - RAW_RESPONSE=$(gh api graphql -f query=' - query { - repository(owner: "'"$OWNER"'", name: "'"$REPO"'") { - pullRequest(number: '$PR_NUMBER') { - projectItems(first: 5) { - nodes { - id - project { + - name: Debug – Fetch PR Project Items + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + OWNER=${{ github.repository_owner }} + REPO=${{ github.event.repository.name }} + + echo "Fetching raw project item data for PR #$PR_NUMBER..." + + RAW_RESPONSE=$(gh api graphql -f query=' + query { + repository(owner: "'"$OWNER"'", name: "'"$REPO"'") { + pullRequest(number: '$PR_NUMBER') { + projectItems(first: 5) { + nodes { id + project { + id + } } } } } - } - }') - - echo "Raw GraphQL Response: $RAW_RESPONSE" + }') + + echo "Raw GraphQL Response: $RAW_RESPONSE" - name: Get PR Project Item ID id: get_project_item