From 2a07f26d1973d4417fa6b48caf2150dcad0ad405 Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Fri, 21 Jun 2024 04:52:04 +0930 Subject: [PATCH 01/36] Update README.md (#74) --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c9d7b58..c8378c8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Profilarr -Profilarr is a Python-based tool designed to add import/export/sync functionality to the \*arr suite. It offers a user-friendly way to export existing custom formats / profiles, import new ones or sync a master instance of Radarr / Sonarr with extras. +Profilarr is a Python-based tool designed to add import/export/sync/delete functionality to the \*arr suite. It offers a user-friendly way to: +- Export existing custom formats / profiles +- Import new custom formats / profiles +- Sync a master instance of Radarr / Sonarr with other instances +- Delete existing custom formats / quality profiles ## Discord From 8ef3339f75b83c13e3764491e0ff2829b2374927 Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Fri, 28 Jun 2024 07:35:43 +0930 Subject: [PATCH 02/36] workflow: add issue to project (#77) --- .github/workflows/add-issue-to-project.yml | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/add-issue-to-project.yml diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml new file mode 100644 index 0000000..b14f99a --- /dev/null +++ b/.github/workflows/add-issue-to-project.yml @@ -0,0 +1,86 @@ +name: Add Issue to Project + +on: + issues: + types: [opened] + +jobs: + add-to-project: + name: Add issue to project + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@v0.5.0 + with: + project-url: https://github.com/orgs/Dictionarry-Hub/projects/1 + github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} + + - name: Set component, type, and status + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NODE_ID: ${{ github.event.issue.node_id }} + run: | + # Set component to "Profilarr" + gh api graphql -f query=' + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $fieldId + value: { + singleSelectOptionId: $value + } + }) { + projectV2Item { + id + } + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${ISSUE_NODE_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCr_E" -f value="48fc49c7" + + # Set status to "Backlog" + gh api graphql -f query=' + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $fieldId + value: { + singleSelectOptionId: $value + } + }) { + projectV2Item { + id + } + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${ISSUE_NODE_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="f75ad846" + + # Get the label of the issue + LABEL=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.labels[0].name') + + # Set issue type based on label + ISSUE_TYPE_ID=$(case $LABEL in + "bug") echo "b760225f" ;; + "feature request") echo "1341bde2" ;; + "improvement") echo "cb34d96f" ;; + "documentation") echo "269885d0" ;; + "refactor") echo "4996f537" ;; + "infrastructure") echo "45a91bfe" ;; + *) echo "" ;; + esac) + + if [ ! -z "$ISSUE_TYPE_ID" ]; then + gh api graphql -f query=' + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $fieldId + value: { + singleSelectOptionId: $value + } + }) { + projectV2Item { + id + } + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${ISSUE_NODE_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID" + fi \ No newline at end of file From 2f58bb7d952f681d608b37118806efde5f8c7355 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 07:39:35 +0930 Subject: [PATCH 03/36] workflows: project PAT added --- .github/workflows/add-issue-to-project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index b14f99a..6488a33 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -16,7 +16,7 @@ jobs: - name: Set component, type, and status env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} ISSUE_NODE_ID: ${{ github.event.issue.node_id }} run: | # Set component to "Profilarr" From cf90bce093fe256b297cb9759835bf4d1a302bce Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 07:43:07 +0930 Subject: [PATCH 04/36] bugfix: get issue ID after item creation --- .github/workflows/add-issue-to-project.yml | 38 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index 6488a33..f2a3d6c 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -9,16 +9,40 @@ jobs: name: Add issue to project runs-on: ubuntu-latest steps: - - uses: actions/add-to-project@v0.5.0 + - name: Add to Project + id: add-to-project + uses: actions/add-to-project@v0.5.0 with: project-url: https://github.com/orgs/Dictionarry-Hub/projects/1 github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} - - name: Set component, type, and status + - name: Get project item ID + id: get-project-item-id env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} ISSUE_NODE_ID: ${{ github.event.issue.node_id }} run: | + item_id=$(gh api graphql -f query=' + query($org: String!, $number: Int!, $nodeId: ID!) { + organization(login: $org){ + projectV2(number: $number) { + items(first: 1, filter: {ids: [$nodeId]}) { + nodes { + id + } + } + } + } + }' -f org="Dictionarry-Hub" -F number=1 -f nodeId=$ISSUE_NODE_ID --jq '.data.organization.projectV2.items.nodes[0].id') + echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_OUTPUT + + - name: Set component, type, and status + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ITEM_ID: ${{ steps.get-project-item-id.outputs.PROJECT_ITEM_ID }} + run: | + echo "Project Item ID: ${PROJECT_ITEM_ID}" + # Set component to "Profilarr" gh api graphql -f query=' mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { @@ -34,7 +58,7 @@ jobs: id } } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${ISSUE_NODE_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCr_E" -f value="48fc49c7" + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCr_E" -f value="48fc49c7" # Set status to "Backlog" gh api graphql -f query=' @@ -51,7 +75,7 @@ jobs: id } } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${ISSUE_NODE_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="f75ad846" + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="f75ad846" # Get the label of the issue LABEL=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.labels[0].name') @@ -79,8 +103,8 @@ jobs: } }) { projectV2Item { - id - } + id } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${ISSUE_NODE_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID" + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID" fi \ No newline at end of file From 1cd14d3d0479146b9de4eb2739a5730effa55bea Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 07:46:15 +0930 Subject: [PATCH 05/36] bugfix: Resolve project item ID retrieval in GitHub Actions workflow --- .github/workflows/add-issue-to-project.yml | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index f2a3d6c..b672dbb 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -20,20 +20,26 @@ jobs: id: get-project-item-id env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - ISSUE_NODE_ID: ${{ github.event.issue.node_id }} + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + ISSUE_ID: ${{ github.event.issue.node_id }} run: | item_id=$(gh api graphql -f query=' - query($org: String!, $number: Int!, $nodeId: ID!) { - organization(login: $org){ - projectV2(number: $number) { - items(first: 1, filter: {ids: [$nodeId]}) { + query($project:ID!, $issue:ID!) { + node(id: $project) { + ... on ProjectV2 { + items(first: 100) { nodes { id + content { + ... on Issue { + id + } + } } } } } - }' -f org="Dictionarry-Hub" -F number=1 -f nodeId=$ISSUE_NODE_ID --jq '.data.organization.projectV2.items.nodes[0].id') + }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.node.items.nodes[] | select(.content.id == env.ISSUE_ID) | .id') echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_OUTPUT - name: Set component, type, and status @@ -103,8 +109,8 @@ jobs: } }) { projectV2Item { - id + id + } } - } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID" + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID" fi \ No newline at end of file From 20ee6ae96827d8ebf3c1f968aa66d597a4b03510 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 07:48:26 +0930 Subject: [PATCH 06/36] bugfix: Correct project item ID retrieval in GitHub Actions workflow --- .github/workflows/add-issue-to-project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index b672dbb..6bf353f 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -39,7 +39,7 @@ jobs: } } } - }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.node.items.nodes[] | select(.content.id == env.ISSUE_ID) | .id') + }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.node.items.nodes[] | select(.content.id == $ISSUE_ID) | .id') echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_OUTPUT - name: Set component, type, and status From 6b3051e7f8ce9e1681cbed2f7e8d031de04643ca Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 07:51:01 +0930 Subject: [PATCH 07/36] bugfix: add sleep before finding ID number --- .github/workflows/add-issue-to-project.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index 6bf353f..0f49837 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -15,16 +15,19 @@ jobs: with: project-url: https://github.com/orgs/Dictionarry-Hub/projects/1 github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} - + + - name: Wait for project item to be created + run: sleep 10 + - name: Get project item ID id: get-project-item-id env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" - ISSUE_ID: ${{ github.event.issue.node_id }} + ISSUE_NUMBER: ${{ github.event.issue.number }} run: | item_id=$(gh api graphql -f query=' - query($project:ID!, $issue:ID!) { + query($project:ID!, $number:Int!) { node(id: $project) { ... on ProjectV2 { items(first: 100) { @@ -32,14 +35,14 @@ jobs: id content { ... on Issue { - id + number } } } } } } - }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.node.items.nodes[] | select(.content.id == $ISSUE_ID) | .id') + }' -f project=$PROJECT_ID -F number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id') echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_OUTPUT - name: Set component, type, and status From d33019c64beb814c5d585ced6ec6c26e40dfe740 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 07:54:55 +0930 Subject: [PATCH 08/36] bugfix: debug output to see where issue lies --- .github/workflows/add-issue-to-project.yml | 38 +++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index 0f49837..9cd4495 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -26,8 +26,9 @@ jobs: PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" ISSUE_NUMBER: ${{ github.event.issue.number }} run: | + echo "Fetching project item ID for issue number: $ISSUE_NUMBER" item_id=$(gh api graphql -f query=' - query($project:ID!, $number:Int!) { + query($project:ID!) { node(id: $project) { ... on ProjectV2 { items(first: 100) { @@ -42,18 +43,24 @@ jobs: } } } - }' -f project=$PROJECT_ID -F number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id') - echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_OUTPUT + }' -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id') + if [ -z "$item_id" ]; then + echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" + exit 1 + else + echo "Project item ID found: $item_id" + echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_OUTPUT + fi - name: Set component, type, and status env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ITEM_ID: ${{ steps.get-project-item-id.outputs.PROJECT_ITEM_ID }} run: | - echo "Project Item ID: ${PROJECT_ITEM_ID}" + echo "Setting fields for Project Item ID: ${PROJECT_ITEM_ID}" # Set component to "Profilarr" - gh api graphql -f query=' + result=$(gh api graphql -f query=' mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { updateProjectV2ItemFieldValue(input: { projectId: $project @@ -67,10 +74,11 @@ jobs: id } } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCr_E" -f value="48fc49c7" + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCr_E" -f value="48fc49c7") + echo "Set component result: $result" # Set status to "Backlog" - gh api graphql -f query=' + result=$(gh api graphql -f query=' mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { updateProjectV2ItemFieldValue(input: { projectId: $project @@ -84,10 +92,12 @@ jobs: id } } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="f75ad846" + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="f75ad846") + echo "Set status result: $result" # Get the label of the issue LABEL=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.labels[0].name') + echo "Issue label: $LABEL" # Set issue type based on label ISSUE_TYPE_ID=$(case $LABEL in @@ -100,8 +110,11 @@ jobs: *) echo "" ;; esac) - if [ ! -z "$ISSUE_TYPE_ID" ]; then - gh api graphql -f query=' + if [ -z "$ISSUE_TYPE_ID" ]; then + echo "No matching issue type for label: $LABEL" + else + echo "Setting issue type to ID: $ISSUE_TYPE_ID" + result=$(gh api graphql -f query=' mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { updateProjectV2ItemFieldValue(input: { projectId: $project @@ -115,5 +128,6 @@ jobs: id } } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID" - fi \ No newline at end of file + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID") + echo "Set issue type result: $result" + fi From a15aa44d70f19b970c800056f35743d16b69a10e Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 07:57:25 +0930 Subject: [PATCH 09/36] bugfix: fixed jq --- .github/workflows/add-issue-to-project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index 9cd4495..6b80dff 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -43,7 +43,7 @@ jobs: } } } - }' -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id') + }' -f project=$PROJECT_ID --jq ".data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id" -F number=$ISSUE_NUMBER) if [ -z "$item_id" ]; then echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" exit 1 From ffc0ba7dfd1c929f2af09fb882d829820527dab7 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:00:26 +0930 Subject: [PATCH 10/36] bugfix: Fix issue type assignment based on issue label case sensitivity --- .github/workflows/add-issue-to-project.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index 6b80dff..e8c0fed 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -99,8 +99,11 @@ jobs: LABEL=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.labels[0].name') echo "Issue label: $LABEL" + # Convert label to lowercase for comparison + LABEL_LOWER=$(echo "$LABEL" | tr '[:upper:]' '[:lower:]') + # Set issue type based on label - ISSUE_TYPE_ID=$(case $LABEL in + ISSUE_TYPE_ID=$(case $LABEL_LOWER in "bug") echo "b760225f" ;; "feature request") echo "1341bde2" ;; "improvement") echo "cb34d96f" ;; @@ -130,4 +133,4 @@ jobs: } }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID") echo "Set issue type result: $result" - fi + fi \ No newline at end of file From 7282ff7d6c4f13e5ebb7488aae74ba0327eaec68 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:03:41 +0930 Subject: [PATCH 11/36] bugfix: remove timer --- .github/workflows/add-issue-to-project.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index e8c0fed..835abdd 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -16,9 +16,6 @@ jobs: project-url: https://github.com/orgs/Dictionarry-Hub/projects/1 github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} - - name: Wait for project item to be created - run: sleep 10 - - name: Get project item ID id: get-project-item-id env: From 684566fa85efec93716177c6b43cccd34da4864f Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:14:44 +0930 Subject: [PATCH 12/36] feature: Set issue status to "In Development" on branch creation --- .github/workflows/new-branch-created.yml | 99 ++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .github/workflows/new-branch-created.yml diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml new file mode 100644 index 0000000..e06ce15 --- /dev/null +++ b/.github/workflows/new-branch-created.yml @@ -0,0 +1,99 @@ +name: Set Issue to In Development on Branch Creation + +on: + create: + branches: + - '*' + +jobs: + update-issue-status: + runs-on: ubuntu-latest + steps: + - name: Extract issue number from branch name + id: extract-issue-number + run: | + BRANCH_NAME="${GITHUB_REF##*/}" + if [[ "$BRANCH_NAME" =~ ^([0-9]+)- ]]; then + ISSUE_NUMBER="${BASH_REMATCH[1]}" + echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV + else + echo "No issue number found in branch name." + exit 1 + fi + + - name: Get project data + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + ORGANIZATION: Dictionarry-Hub + PROJECT_NUMBER: 1 + run: | + gh api graphql -f query=' + query($org: String!, $number: Int!) { + organization(login: $org){ + projectV2(number: $number) { + id + fields(first:20) { + nodes { + ... on ProjectV2Field { + id + name + } + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json + + echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV + echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV + echo 'IN_DEVELOPMENT_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="In Development") |.id' project_data.json) >> $GITHUB_ENV + + - name: Set issue status to "In Development" + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ID: ${{ env.PROJECT_ID }} + ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} + STATUS_FIELD_ID: ${{ env.STATUS_FIELD_ID }} + IN_DEVELOPMENT_OPTION_ID: ${{ env.IN_DEVELOPMENT_OPTION_ID }} + run: | + # Get the content ID of the issue + ISSUE_NODE_ID=$(gh api graphql -f query=' + query($repository: String!, $owner: String!, $number: Int!) { + repository(name: $repository, owner: $owner) { + issue(number: $number) { + id + } + } + }' -f repository="${{ github.repository }}" -f owner="${{ github.repository_owner.login }}" -f number=$ISSUE_NUMBER --jq '.data.repository.issue.id') + echo "ISSUE_NODE_ID=$ISSUE_NODE_ID" + + # Set the status to "In Development" + result=$(gh api graphql -f query=' + mutation ( + $project: ID! + $item: ID! + $status_field: ID! + $status_value: String! + ) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $status_field + value: { + singleSelectOptionId: $status_value + } + }) { + projectV2Item { + id + } + } + }' -f project=$PROJECT_ID -f item=$ISSUE_NODE_ID -f status_field=$STATUS_FIELD_ID -f status_value=$IN_DEVELOPMENT_OPTION_ID) + echo "Set status result: $result" From 564202f318bf03cb187074c32f84ac46060f323a Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:17:16 +0930 Subject: [PATCH 13/36] bugfix: Correct issue number handling and status update --- .github/workflows/new-branch-created.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index e06ce15..9900985 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -96,4 +96,4 @@ jobs: } } }' -f project=$PROJECT_ID -f item=$ISSUE_NODE_ID -f status_field=$STATUS_FIELD_ID -f status_value=$IN_DEVELOPMENT_OPTION_ID) - echo "Set status result: $result" + echo "Set status result: $result" \ No newline at end of file From fe227e105b8b3c08b8ace12a0767f465207a7fe3 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:19:24 +0930 Subject: [PATCH 14/36] bugfix: Correct issue number handling and status update --- .github/workflows/new-branch-created.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index 9900985..db46ef2 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -56,7 +56,7 @@ jobs: echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV echo 'IN_DEVELOPMENT_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="In Development") |.id' project_data.json) >> $GITHUB_ENV - - name: Set issue status to "In Development" + - name: Set issue status to "In Development" env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ID: ${{ env.PROJECT_ID }} @@ -72,7 +72,7 @@ jobs: id } } - }' -f repository="${{ github.repository }}" -f owner="${{ github.repository_owner.login }}" -f number=$ISSUE_NUMBER --jq '.data.repository.issue.id') + }' -f repository="${{ github.repository }}" -f owner="${{ github.repository_owner.login }}" -F number=$ISSUE_NUMBER --jq '.data.repository.issue.id') echo "ISSUE_NODE_ID=$ISSUE_NODE_ID" # Set the status to "In Development" @@ -96,4 +96,4 @@ jobs: } } }' -f project=$PROJECT_ID -f item=$ISSUE_NODE_ID -f status_field=$STATUS_FIELD_ID -f status_value=$IN_DEVELOPMENT_OPTION_ID) - echo "Set status result: $result" \ No newline at end of file + echo "Set status result: $result" From cbc909f9ae44dafb85e612949a5c7a6d6f440698 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:21:58 +0930 Subject: [PATCH 15/36] bigfix: tab syntax fixed --- .github/workflows/new-branch-created.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index db46ef2..b8c1660 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -56,7 +56,7 @@ jobs: echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV echo 'IN_DEVELOPMENT_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="In Development") |.id' project_data.json) >> $GITHUB_ENV - - name: Set issue status to "In Development" + - name: Set issue status to "In Development" env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ID: ${{ env.PROJECT_ID }} From bfc04afc14c00df8f132957adbb5c8f3ceb06de2 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:28:01 +0930 Subject: [PATCH 16/36] bugfix: Correct issue number extraction and project item status update --- .github/workflows/add-issue-to-project.yml | 96 +++++----------------- 1 file changed, 21 insertions(+), 75 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index 835abdd..1e6c8df 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -1,27 +1,33 @@ -name: Add Issue to Project +name: Set Issue to In Development on Branch Creation on: - issues: - types: [opened] + create: + branches: + - '*' jobs: - add-to-project: - name: Add issue to project + update-issue-status: + name: Update issue status to In Development runs-on: ubuntu-latest steps: - - name: Add to Project - id: add-to-project - uses: actions/add-to-project@v0.5.0 - with: - project-url: https://github.com/orgs/Dictionarry-Hub/projects/1 - github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} + - name: Extract issue number from branch name + id: extract-issue-number + run: | + BRANCH_NAME="${GITHUB_REF##*/}" + if [[ "$BRANCH_NAME" =~ ^([0-9]+)- ]]; then + ISSUE_NUMBER="${BASH_REMATCH[1]}" + echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV + else + echo "No issue number found in branch name." + exit 1 + fi - name: Get project item ID id: get-project-item-id env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" - ISSUE_NUMBER: ${{ github.event.issue.number }} + ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} run: | echo "Fetching project item ID for issue number: $ISSUE_NUMBER" item_id=$(gh api graphql -f query=' @@ -49,14 +55,12 @@ jobs: echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_OUTPUT fi - - name: Set component, type, and status + - name: Set status to "In Development" env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ITEM_ID: ${{ steps.get-project-item-id.outputs.PROJECT_ITEM_ID }} run: | - echo "Setting fields for Project Item ID: ${PROJECT_ITEM_ID}" - - # Set component to "Profilarr" + echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" result=$(gh api graphql -f query=' mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { updateProjectV2ItemFieldValue(input: { @@ -71,63 +75,5 @@ jobs: id } } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCr_E" -f value="48fc49c7") - echo "Set component result: $result" - - # Set status to "Backlog" - result=$(gh api graphql -f query=' - mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { - updateProjectV2ItemFieldValue(input: { - projectId: $project - itemId: $item - fieldId: $fieldId - value: { - singleSelectOptionId: $value - } - }) { - projectV2Item { - id - } - } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="f75ad846") + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="in-development") echo "Set status result: $result" - - # Get the label of the issue - LABEL=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.labels[0].name') - echo "Issue label: $LABEL" - - # Convert label to lowercase for comparison - LABEL_LOWER=$(echo "$LABEL" | tr '[:upper:]' '[:lower:]') - - # Set issue type based on label - ISSUE_TYPE_ID=$(case $LABEL_LOWER in - "bug") echo "b760225f" ;; - "feature request") echo "1341bde2" ;; - "improvement") echo "cb34d96f" ;; - "documentation") echo "269885d0" ;; - "refactor") echo "4996f537" ;; - "infrastructure") echo "45a91bfe" ;; - *) echo "" ;; - esac) - - if [ -z "$ISSUE_TYPE_ID" ]; then - echo "No matching issue type for label: $LABEL" - else - echo "Setting issue type to ID: $ISSUE_TYPE_ID" - result=$(gh api graphql -f query=' - mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { - updateProjectV2ItemFieldValue(input: { - projectId: $project - itemId: $item - fieldId: $fieldId - value: { - singleSelectOptionId: $value - } - }) { - projectV2Item { - id - } - } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID") - echo "Set issue type result: $result" - fi \ No newline at end of file From 2241be7a7499e6a82ae63249d18c60171b29b9fe Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:29:33 +0930 Subject: [PATCH 17/36] bugfix: Correct issue number extraction and project item status update --- .github/workflows/add-issue-to-project.yml | 96 +++++++++++++++++----- .github/workflows/new-branch-created.yml | 2 +- 2 files changed, 76 insertions(+), 22 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index 1e6c8df..835abdd 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -1,33 +1,27 @@ -name: Set Issue to In Development on Branch Creation +name: Add Issue to Project on: - create: - branches: - - '*' + issues: + types: [opened] jobs: - update-issue-status: - name: Update issue status to In Development + add-to-project: + name: Add issue to project runs-on: ubuntu-latest steps: - - name: Extract issue number from branch name - id: extract-issue-number - run: | - BRANCH_NAME="${GITHUB_REF##*/}" - if [[ "$BRANCH_NAME" =~ ^([0-9]+)- ]]; then - ISSUE_NUMBER="${BASH_REMATCH[1]}" - echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV - else - echo "No issue number found in branch name." - exit 1 - fi + - name: Add to Project + id: add-to-project + uses: actions/add-to-project@v0.5.0 + with: + project-url: https://github.com/orgs/Dictionarry-Hub/projects/1 + github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} - name: Get project item ID id: get-project-item-id env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" - ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} + ISSUE_NUMBER: ${{ github.event.issue.number }} run: | echo "Fetching project item ID for issue number: $ISSUE_NUMBER" item_id=$(gh api graphql -f query=' @@ -55,12 +49,14 @@ jobs: echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_OUTPUT fi - - name: Set status to "In Development" + - name: Set component, type, and status env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ITEM_ID: ${{ steps.get-project-item-id.outputs.PROJECT_ITEM_ID }} run: | - echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" + echo "Setting fields for Project Item ID: ${PROJECT_ITEM_ID}" + + # Set component to "Profilarr" result=$(gh api graphql -f query=' mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { updateProjectV2ItemFieldValue(input: { @@ -75,5 +71,63 @@ jobs: id } } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="in-development") + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCr_E" -f value="48fc49c7") + echo "Set component result: $result" + + # Set status to "Backlog" + result=$(gh api graphql -f query=' + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $fieldId + value: { + singleSelectOptionId: $value + } + }) { + projectV2Item { + id + } + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="f75ad846") echo "Set status result: $result" + + # Get the label of the issue + LABEL=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.labels[0].name') + echo "Issue label: $LABEL" + + # Convert label to lowercase for comparison + LABEL_LOWER=$(echo "$LABEL" | tr '[:upper:]' '[:lower:]') + + # Set issue type based on label + ISSUE_TYPE_ID=$(case $LABEL_LOWER in + "bug") echo "b760225f" ;; + "feature request") echo "1341bde2" ;; + "improvement") echo "cb34d96f" ;; + "documentation") echo "269885d0" ;; + "refactor") echo "4996f537" ;; + "infrastructure") echo "45a91bfe" ;; + *) echo "" ;; + esac) + + if [ -z "$ISSUE_TYPE_ID" ]; then + echo "No matching issue type for label: $LABEL" + else + echo "Setting issue type to ID: $ISSUE_TYPE_ID" + result=$(gh api graphql -f query=' + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $fieldId + value: { + singleSelectOptionId: $value + } + }) { + projectV2Item { + id + } + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCswQ" -f value="$ISSUE_TYPE_ID") + echo "Set issue type result: $result" + fi \ No newline at end of file diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index b8c1660..e06ce15 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -72,7 +72,7 @@ jobs: id } } - }' -f repository="${{ github.repository }}" -f owner="${{ github.repository_owner.login }}" -F number=$ISSUE_NUMBER --jq '.data.repository.issue.id') + }' -f repository="${{ github.repository }}" -f owner="${{ github.repository_owner.login }}" -f number=$ISSUE_NUMBER --jq '.data.repository.issue.id') echo "ISSUE_NODE_ID=$ISSUE_NODE_ID" # Set the status to "In Development" From d3c9d5a19beb58e96917cb70c7f6e476e0852945 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:38:10 +0930 Subject: [PATCH 18/36] workflow: Added workflow to update issue status to 'In Development' when branches are created from issues --- .github/workflows/new-branch-created.yml | 100 ++++++++--------------- 1 file changed, 36 insertions(+), 64 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index e06ce15..10625a2 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -1,99 +1,71 @@ -name: Set Issue to In Development on Branch Creation +name: Update Issue Status to In Development on: - create: + push: branches: - - '*' + - '*-*' jobs: - update-issue-status: + update-status: runs-on: ubuntu-latest steps: - - name: Extract issue number from branch name + - name: Extract Issue Number from Branch Name id: extract-issue-number run: | - BRANCH_NAME="${GITHUB_REF##*/}" - if [[ "$BRANCH_NAME" =~ ^([0-9]+)- ]]; then - ISSUE_NUMBER="${BASH_REMATCH[1]}" - echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV - else - echo "No issue number found in branch name." - exit 1 - fi + ISSUE_NUMBER=$(echo $GITHUB_REF_NAME | cut -d'-' -f1) + echo "Issue Number extracted: $ISSUE_NUMBER" + echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV - - name: Get project data + - name: Get project item ID + id: get-project-item-id env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - ORGANIZATION: Dictionarry-Hub - PROJECT_NUMBER: 1 + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" run: | - gh api graphql -f query=' - query($org: String!, $number: Int!) { - organization(login: $org){ - projectV2(number: $number) { - id - fields(first:20) { + echo "Fetching project item ID for issue number: $ISSUE_NUMBER" + item_id=$(gh api graphql -f query=' + query($project:ID!, $number:Int!) { + node(id: $project) { + ... on ProjectV2 { + items(first: 100) { nodes { - ... on ProjectV2Field { - id - name - } - ... on ProjectV2SingleSelectField { - id - name - options { - id - name + id + content { + ... on Issue { + number } } } } } } - }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json + }' -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq ".data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id") + if [ -z "$item_id" ]; then + echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" + exit 1 + else: + echo "Project item ID found: $item_id" + echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV - echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV - echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV - echo 'IN_DEVELOPMENT_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="In Development") |.id' project_data.json) >> $GITHUB_ENV - - - name: Set issue status to "In Development" + - name: Set status to In Development env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - PROJECT_ID: ${{ env.PROJECT_ID }} - ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} - STATUS_FIELD_ID: ${{ env.STATUS_FIELD_ID }} - IN_DEVELOPMENT_OPTION_ID: ${{ env.IN_DEVELOPMENT_OPTION_ID }} + PROJECT_ITEM_ID: ${{ env.PROJECT_ITEM_ID }} run: | - # Get the content ID of the issue - ISSUE_NODE_ID=$(gh api graphql -f query=' - query($repository: String!, $owner: String!, $number: Int!) { - repository(name: $repository, owner: $owner) { - issue(number: $number) { - id - } - } - }' -f repository="${{ github.repository }}" -f owner="${{ github.repository_owner.login }}" -f number=$ISSUE_NUMBER --jq '.data.repository.issue.id') - echo "ISSUE_NODE_ID=$ISSUE_NODE_ID" - - # Set the status to "In Development" + echo "Setting status for Project Item ID: $PROJECT_ITEM_ID" result=$(gh api graphql -f query=' - mutation ( - $project: ID! - $item: ID! - $status_field: ID! - $status_value: String! - ) { + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { updateProjectV2ItemFieldValue(input: { projectId: $project itemId: $item - fieldId: $status_field - value: { - singleSelectOptionId: $status_value + fieldId: $fieldId + value: { + singleSelectOptionId: $value } }) { projectV2Item { id } } - }' -f project=$PROJECT_ID -f item=$ISSUE_NODE_ID -f status_field=$STATUS_FIELD_ID -f status_value=$IN_DEVELOPMENT_OPTION_ID) + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="in_development_option_id") # Replace "in_development_option_id" with your actual option ID for "In Development" echo "Set status result: $result" From 3c205406780d94d82c4ede84b500600708e71407 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:39:59 +0930 Subject: [PATCH 19/36] bugfix: Fixed the GraphQL query in GitHub Actions workflow to properly use the declared variable for fetching the project item ID. --- .github/workflows/new-branch-created.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index 10625a2..2abd376 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -39,14 +39,15 @@ jobs: } } } - }' -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq ".data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id") + }' -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == $number) | .id') if [ -z "$item_id" ]; then echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" exit 1 - else: + else echo "Project item ID found: $item_id" echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV + - name: Set status to In Development env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} From 8402ec147d70d9893cf324a80fbb219bb4449b9e Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:41:30 +0930 Subject: [PATCH 20/36] bugfix: Enhanced debugging for the GitHub Actions workflow to identify issues in fetching project item IDs. --- .github/workflows/new-branch-created.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index 2abd376..eb0cdbc 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -23,8 +23,8 @@ jobs: PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" run: | echo "Fetching project item ID for issue number: $ISSUE_NUMBER" - item_id=$(gh api graphql -f query=' - query($project:ID!, $number:Int!) { + QUERY=' + query fetchProjectItem($project:ID!, $number:Int!) { node(id: $project) { ... on ProjectV2 { items(first: 100) { @@ -39,7 +39,9 @@ jobs: } } } - }' -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == $number) | .id') + }' + echo "Running query with PROJECT_ID: $PROJECT_ID and ISSUE_NUMBER: $ISSUE_NUMBER" + item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == $number) | .id') if [ -z "$item_id" ]; then echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" exit 1 @@ -48,6 +50,7 @@ jobs: echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV + - name: Set status to In Development env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} From 3a773c3050bc056d01d1ca39cf16f887b0f0aeef Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:43:48 +0930 Subject: [PATCH 21/36] bugfix: Adjusted the GitHub Actions workflow to trigger on branch creation and corrected the GraphQL query. --- .github/workflows/new-branch-created.yml | 40 +++++++++++------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index eb0cdbc..514ed23 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -1,7 +1,7 @@ name: Update Issue Status to In Development on: - push: + create: branches: - '*-*' @@ -19,44 +19,40 @@ jobs: - name: Get project item ID id: get-project-item-id env: - GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" run: | echo "Fetching project item ID for issue number: $ISSUE_NUMBER" - QUERY=' - query fetchProjectItem($project:ID!, $number:Int!) { - node(id: $project) { - ... on ProjectV2 { - items(first: 100) { - nodes { - id - content { - ... on Issue { - number - } + QUERY='query fetchProjectItem($project:ID!, $number:Int!) { + node(id: $project) { + ... on ProjectV2 { + items(first: 100) { + nodes { + id + content { + ... on Issue { + number } } } } } - }' - echo "Running query with PROJECT_ID: $PROJECT_ID and ISSUE_NUMBER: $ISSUE_NUMBER" - item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == $number) | .id') + } + }' + item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == env.ISSUE_NUMBER) | .id') if [ -z "$item_id" ]; then echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" exit 1 - else + else: echo "Project item ID found: $item_id" echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV - - - name: Set status to In Development env: - GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - PROJECT_ITEM_ID: ${{ env.PROJECT_ITEM_ID }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PROJECT_ITEM_ID: ${{ steps.get-project-item-id.outputs.PROJECT_ITEM_ID }} run: | - echo "Setting status for Project Item ID: $PROJECT_ITEM_ID" + echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" result=$(gh api graphql -f query=' mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { updateProjectV2ItemFieldValue(input: { From 2dc8c5bcba7009b83d7b3fc97b194d78d00e3d64 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:50:53 +0930 Subject: [PATCH 22/36] bugfix: Correct environment variable usage and syntax in workflow --- .github/workflows/new-branch-created.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index 514ed23..f60083d 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -39,13 +39,14 @@ jobs: } } }' - item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == env.ISSUE_NUMBER) | .id') + item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == '"$ISSUE_NUMBER"') | .id') if [ -z "$item_id" ]; then echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" exit 1 - else: + else echo "Project item ID found: $item_id" echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV + fi - name: Set status to In Development env: From d2b337fced342b949ff2c30f8051fce584abb560 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:54:18 +0930 Subject: [PATCH 23/36] bugfix: Correct environment variable usage and syntax in workflow --- .github/workflows/new-branch-created.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index f60083d..e8f790f 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -23,7 +23,8 @@ jobs: PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" run: | echo "Fetching project item ID for issue number: $ISSUE_NUMBER" - QUERY='query fetchProjectItem($project:ID!, $number:Int!) { + QUERY=' + query fetchProjectItem($project: ID!) { node(id: $project) { ... on ProjectV2 { items(first: 100) { @@ -39,7 +40,7 @@ jobs: } } }' - item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID -f number=$ISSUE_NUMBER --jq '.data.node.items.nodes[] | select(.content.number == '"$ISSUE_NUMBER"') | .id') + item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.content.number == '"$ISSUE_NUMBER"') | .id') if [ -z "$item_id" ]; then echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" exit 1 @@ -55,7 +56,7 @@ jobs: run: | echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" result=$(gh api graphql -f query=' - mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + mutation($project: ID!, $item: ID!, $fieldId: ID!, $value: String!) { updateProjectV2ItemFieldValue(input: { projectId: $project itemId: $item From ca126d0c010706179c1fc73e0876ec4f52549298 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 08:56:59 +0930 Subject: [PATCH 24/36] bugfix: Correct environment variable usage and syntax in workflow --- .github/workflows/new-branch-created.yml | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index e8f790f..8700d9a 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -19,28 +19,28 @@ jobs: - name: Get project item ID id: get-project-item-id env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} run: | echo "Fetching project item ID for issue number: $ISSUE_NUMBER" - QUERY=' - query fetchProjectItem($project: ID!) { - node(id: $project) { - ... on ProjectV2 { - items(first: 100) { - nodes { - id - content { - ... on Issue { - number + item_id=$(gh api graphql -f query=' + query($project:ID!) { + node(id: $project) { + ... on ProjectV2 { + items(first: 100) { + nodes { + id + content { + ... on Issue { + number + } } } } } } - } - }' - item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.content.number == '"$ISSUE_NUMBER"') | .id') + }' -f project=$PROJECT_ID --jq ".data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id") if [ -z "$item_id" ]; then echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" exit 1 @@ -51,12 +51,12 @@ jobs: - name: Set status to In Development env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PROJECT_ITEM_ID: ${{ steps.get-project-item-id.outputs.PROJECT_ITEM_ID }} + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ITEM_ID: ${{ env.PROJECT_ITEM_ID }} run: | echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" result=$(gh api graphql -f query=' - mutation($project: ID!, $item: ID!, $fieldId: ID!, $value: String!) { + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { updateProjectV2ItemFieldValue(input: { projectId: $project itemId: $item @@ -70,4 +70,4 @@ jobs: } } }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="in_development_option_id") # Replace "in_development_option_id" with your actual option ID for "In Development" - echo "Set status result: $result" + echo "Set status result: $resul From 9def9b6b305125e1112ffd3327594a165d339624 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 09:01:10 +0930 Subject: [PATCH 25/36] bugfix: Correct dynamic retrieval of field and option IDs for setting issue status --- .github/workflows/new-branch-created.yml | 71 +++++++++++++++++++----- 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/.github/workflows/new-branch-created.yml b/.github/workflows/new-branch-created.yml index 8700d9a..8e5a2a0 100644 --- a/.github/workflows/new-branch-created.yml +++ b/.github/workflows/new-branch-created.yml @@ -21,26 +21,26 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" - ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} run: | echo "Fetching project item ID for issue number: $ISSUE_NUMBER" - item_id=$(gh api graphql -f query=' - query($project:ID!) { - node(id: $project) { - ... on ProjectV2 { - items(first: 100) { - nodes { - id - content { - ... on Issue { - number - } + QUERY=' + query fetchProjectItem($project: ID!) { + node(id: $project) { + ... on ProjectV2 { + items(first: 100) { + nodes { + id + content { + ... on Issue { + number } } } } } - }' -f project=$PROJECT_ID --jq ".data.node.items.nodes[] | select(.content.number == $ISSUE_NUMBER) | .id") + } + }' + item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.content.number == '"$ISSUE_NUMBER"') | .id') if [ -z "$item_id" ]; then echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" exit 1 @@ -49,10 +49,51 @@ jobs: echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV fi + - name: Get single select field ID and options + id: get-field-options + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + run: | + echo "Fetching field ID and options for status" + QUERY=' + query($project:ID!) { + node(id: $project) { + ... on ProjectV2 { + fields(first: 100) { + nodes { + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' + field_data=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.fields.nodes[] | select(.name == "Status")') + field_id=$(echo $field_data | jq -r '.id') + in_development_option_id=$(echo $field_data | jq -r '.options[] | select(.name == "In Development") | .id') + if [ -z "$field_id" ] || [ -z "$in_development_option_id" ]; then + echo "Error: Field ID or In Development option ID not found" + exit 1 + else + echo "Field ID: $field_id" + echo "In Development option ID: $in_development_option_id" + echo "FIELD_ID=$field_id" >> $GITHUB_ENV + echo "IN_DEVELOPMENT_OPTION_ID=$in_development_option_id" >> $GITHUB_ENV + fi + - name: Set status to In Development env: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} PROJECT_ITEM_ID: ${{ env.PROJECT_ITEM_ID }} + FIELD_ID: ${{ env.FIELD_ID }} + IN_DEVELOPMENT_OPTION_ID: ${{ env.IN_DEVELOPMENT_OPTION_ID }} run: | echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" result=$(gh api graphql -f query=' @@ -69,5 +110,5 @@ jobs: id } } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="PVTSSF_lADOCjbMFM4AjuUhzgcCn8s" -f value="in_development_option_id") # Replace "in_development_option_id" with your actual option ID for "In Development" - echo "Set status result: $resul + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="${FIELD_ID}" -f value="${IN_DEVELOPMENT_OPTION_ID}") + echo "Set status result: $result" From 96598fb603db0ef197fbc00a405429ab8d82112d Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 09:09:06 +0930 Subject: [PATCH 26/36] workflow: Set issue status to "Testing" on merge to dev --- .github/workflows/add-to-testing.yml | 117 +++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/add-to-testing.yml diff --git a/.github/workflows/add-to-testing.yml b/.github/workflows/add-to-testing.yml new file mode 100644 index 0000000..85aee45 --- /dev/null +++ b/.github/workflows/add-to-testing.yml @@ -0,0 +1,117 @@ +name: Set Issue Status to Testing on Merge to Dev + +on: + pull_request: + branches: + - dev + types: + - closed + +jobs: + update-status: + if: ${{ github.event.pull_request.merged }} + runs-on: ubuntu-latest + steps: + - name: Extract Issue Number from Branch Name + id: extract-issue-number + run: | + ISSUE_NUMBER=$(echo ${{ github.event.pull_request.head.ref }} | cut -d'-' -f1) + echo "Issue Number extracted: $ISSUE_NUMBER" + echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV + + - name: Get project item ID + id: get-project-item-id + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + run: | + echo "Fetching project item ID for issue number: $ISSUE_NUMBER" + QUERY=' + query fetchProjectItem($project: ID!) { + node(id: $project) { + ... on ProjectV2 { + items(first: 100) { + nodes { + id + content { + ... on Issue { + number + } + } + } + } + } + } + }' + item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.content.number == '"$ISSUE_NUMBER"') | .id') + if [ -z "$item_id" ]; then + echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" + exit 1 + else + echo "Project item ID found: $item_id" + echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV + fi + + - name: Get single select field ID and options + id: get-field-options + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + run: | + echo "Fetching field ID and options for status" + QUERY=' + query($project:ID!) { + node(id: $project) { + ... on ProjectV2 { + fields(first: 100) { + nodes { + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' + field_data=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.fields.nodes[] | select(.name == "Status")') + field_id=$(echo $field_data | jq -r '.id') + testing_option_id=$(echo $field_data | jq -r '.options[] | select(.name == "Testing") | .id') + if [ -z "$field_id" ] || [ -z "$testing_option_id" ]; then + echo "Error: Field ID or Testing option ID not found" + exit 1 + else + echo "Field ID: $field_id" + echo "Testing option ID: $testing_option_id" + echo "FIELD_ID=$field_id" >> $GITHUB_ENV + echo "TESTING_OPTION_ID=$testing_option_id" >> $GITHUB_ENV + fi + + - name: Set status to Testing + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ITEM_ID: ${{ env.PROJECT_ITEM_ID }} + FIELD_ID: ${{ env.FIELD_ID }} + TESTING_OPTION_ID: ${{ env.TESTING_OPTION_ID }} + run: | + echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" + result=$(gh api graphql -f query=' + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $fieldId + value: { + singleSelectOptionId: $value + } + }) { + projectV2Item { + id + } + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="${FIELD_ID}" -f value="${TESTING_OPTION_ID}") + echo "Set status result: $result" From 2f03dfffd004a45922fd6d7fe3f3cfbd8fb8621b Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 09:10:02 +0930 Subject: [PATCH 27/36] workflow: adjusted to main for testing --- .github/workflows/add-to-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-to-testing.yml b/.github/workflows/add-to-testing.yml index 85aee45..cd07db3 100644 --- a/.github/workflows/add-to-testing.yml +++ b/.github/workflows/add-to-testing.yml @@ -3,7 +3,7 @@ name: Set Issue Status to Testing on Merge to Dev on: pull_request: branches: - - dev + - main types: - closed From 6a70fdad13720bbe29b97d82670f2f00e42becc1 Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Fri, 28 Jun 2024 09:14:37 +0930 Subject: [PATCH 28/36] Update README.md (#89) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c8378c8..ab3a77e 100644 --- a/README.md +++ b/README.md @@ -321,3 +321,5 @@ PS Z:\Profilarr> Some custom formats found here have been interated on from the trash guides. Credit for these goes entirely to trash, and can be found on their site here. It is not my intention to steal their work, but rather to build on it and make it more accessible to the average user through my quality profiles. Please check out their site for more information on their work. https://trash-guides.info/ + +Test From e8ac54c7ae8563df0011920dd4c0d7542f7f6f4a Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 09:19:45 +0930 Subject: [PATCH 29/36] workflow: changed to dev for real development --- .github/workflows/add-to-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-to-testing.yml b/.github/workflows/add-to-testing.yml index cd07db3..85aee45 100644 --- a/.github/workflows/add-to-testing.yml +++ b/.github/workflows/add-to-testing.yml @@ -3,7 +3,7 @@ name: Set Issue Status to Testing on Merge to Dev on: pull_request: branches: - - main + - dev types: - closed From e601488798c01848e6a36333249aa8183434129e Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 09:20:43 +0930 Subject: [PATCH 30/36] workflow: Set issues status to "Complete" on merge to main --- .github/workflows/item-complete.yml | 120 ++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 .github/workflows/item-complete.yml diff --git a/.github/workflows/item-complete.yml b/.github/workflows/item-complete.yml new file mode 100644 index 0000000..bfafcfa --- /dev/null +++ b/.github/workflows/item-complete.yml @@ -0,0 +1,120 @@ +name: Update Issues to Complete on Merge to Main + +on: + pull_request: + branches: + - main + types: + - closed + +jobs: + update-issues-status: + if: ${{ github.event.pull_request.merged && github.event.pull_request.head.ref == 'x' }} + runs-on: ubuntu-latest + steps: + - name: Get all issues with status "Testing" + id: get-testing-issues + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + run: | + echo "Fetching all issues with status 'Testing'" + QUERY=' + query($project:ID!) { + node(id: $project) { + ... on ProjectV2 { + items(first: 100) { + nodes { + id + content { + ... on Issue { + number + } + } + fieldValues(first: 10) { + nodes { + ... on ProjectV2ItemFieldSingleSelectValue { + name + field { + ... on ProjectV2SingleSelectField { + name + } + } + } + } + } + } + } + } + } + }' + items=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.fieldValues.nodes[] | select(.name == "Testing")) | .id') + echo "Items with 'Testing' status: $items" + echo "TESTING_ITEMS=$items" >> $GITHUB_ENV + + - name: Get single select field ID and option ID for "Complete" + id: get-complete-option-id + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + run: | + echo "Fetching field ID and options for status" + QUERY=' + query($project:ID!) { + node(id: $project) { + ... on ProjectV2 { + fields(first: 100) { + nodes { + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' + field_data=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.fields.nodes[] | select(.name == "Status")') + field_id=$(echo $field_data | jq -r '.id') + complete_option_id=$(echo $field_data | jq -r '.options[] | select(.name == "Complete") | .id') + if [ -z "$field_id" ] || [ -z "$complete_option_id" ]; then + echo "Error: Field ID or Complete option ID not found" + exit 1 + else + echo "Field ID: $field_id" + echo "Complete option ID: $complete_option_id" + echo "FIELD_ID=$field_id" >> $GITHUB_ENV + echo "COMPLETE_OPTION_ID=$complete_option_id" >> $GITHUB_ENV + fi + + - name: Set status to Complete for all items + if: steps.get-testing-issues.outputs.TESTING_ITEMS != '' + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + FIELD_ID: ${{ env.FIELD_ID }} + COMPLETE_OPTION_ID: ${{ env.COMPLETE_OPTION_ID }} + run: | + IFS=$'\n' read -rd '' -a items <<<"$TESTING_ITEMS" + for item in "${items[@]}"; do + echo "Setting status to Complete for Project Item ID: $item" + result=$(gh api graphql -f query=' + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $fieldId + value: { + singleSelectOptionId: $value + } + }) { + projectV2Item { + id + } + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="$item" -f fieldId="${FIELD_ID}" -f value="${COMPLETE_OPTION_ID}") + echo "Set status result: $result" + done From f91518226063d30d8efec572f99d0d226b22424a Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Fri, 28 Jun 2024 09:24:03 +0930 Subject: [PATCH 31/36] bugfix: remove test line from README (#90) --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index ab3a77e..7404128 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,4 @@ PS Z:\Profilarr> Some custom formats found here have been interated on from the trash guides. Credit for these goes entirely to trash, and can be found on their site here. It is not my intention to steal their work, but rather to build on it and make it more accessible to the average user through my quality profiles. Please check out their site for more information on their work. -https://trash-guides.info/ - -Test +https://trash-guides.info/ \ No newline at end of file From 5c2e252ebbb67278a5e91823103f255ab57236d3 Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Fri, 28 Jun 2024 09:26:31 +0930 Subject: [PATCH 32/36] test: test (#91) --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7404128..d56c77e 100644 --- a/README.md +++ b/README.md @@ -320,4 +320,6 @@ PS Z:\Profilarr> Some custom formats found here have been interated on from the trash guides. Credit for these goes entirely to trash, and can be found on their site here. It is not my intention to steal their work, but rather to build on it and make it more accessible to the average user through my quality profiles. Please check out their site for more information on their work. -https://trash-guides.info/ \ No newline at end of file +https://trash-guides.info/ + +test \ No newline at end of file From 43889b9a44445c9d7aed89e708137735b7fe71f2 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 09:29:48 +0930 Subject: [PATCH 33/36] bugfix: Correct handling of environment variables for updating issue status --- .github/workflows/item-complete.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/item-complete.yml b/.github/workflows/item-complete.yml index bfafcfa..c376076 100644 --- a/.github/workflows/item-complete.yml +++ b/.github/workflows/item-complete.yml @@ -49,6 +49,7 @@ jobs: } }' items=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.fieldValues.nodes[] | select(.name == "Testing")) | .id') + items=$(echo $items | tr '\n' ' ') echo "Items with 'Testing' status: $items" echo "TESTING_ITEMS=$items" >> $GITHUB_ENV @@ -97,8 +98,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} FIELD_ID: ${{ env.FIELD_ID }} COMPLETE_OPTION_ID: ${{ env.COMPLETE_OPTION_ID }} + TESTING_ITEMS: ${{ steps.get-testing-issues.outputs.TESTING_ITEMS }} run: | - IFS=$'\n' read -rd '' -a items <<<"$TESTING_ITEMS" + IFS=' ' read -ra items <<< "$TESTING_ITEMS" for item in "${items[@]}"; do echo "Setting status to Complete for Project Item ID: $item" result=$(gh api graphql -f query=' From 5d5500145e572930dc74e24dbab677f8403c0ef9 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 09:38:35 +0930 Subject: [PATCH 35/36] removed: testing and complete workflows --- .github/workflows/add-to-testing.yml | 117 ------------------------- .github/workflows/item-complete.yml | 122 --------------------------- 2 files changed, 239 deletions(-) delete mode 100644 .github/workflows/add-to-testing.yml delete mode 100644 .github/workflows/item-complete.yml diff --git a/.github/workflows/add-to-testing.yml b/.github/workflows/add-to-testing.yml deleted file mode 100644 index 85aee45..0000000 --- a/.github/workflows/add-to-testing.yml +++ /dev/null @@ -1,117 +0,0 @@ -name: Set Issue Status to Testing on Merge to Dev - -on: - pull_request: - branches: - - dev - types: - - closed - -jobs: - update-status: - if: ${{ github.event.pull_request.merged }} - runs-on: ubuntu-latest - steps: - - name: Extract Issue Number from Branch Name - id: extract-issue-number - run: | - ISSUE_NUMBER=$(echo ${{ github.event.pull_request.head.ref }} | cut -d'-' -f1) - echo "Issue Number extracted: $ISSUE_NUMBER" - echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV - - - name: Get project item ID - id: get-project-item-id - env: - GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" - run: | - echo "Fetching project item ID for issue number: $ISSUE_NUMBER" - QUERY=' - query fetchProjectItem($project: ID!) { - node(id: $project) { - ... on ProjectV2 { - items(first: 100) { - nodes { - id - content { - ... on Issue { - number - } - } - } - } - } - } - }' - item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.content.number == '"$ISSUE_NUMBER"') | .id') - if [ -z "$item_id" ]; then - echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" - exit 1 - else - echo "Project item ID found: $item_id" - echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV - fi - - - name: Get single select field ID and options - id: get-field-options - env: - GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" - run: | - echo "Fetching field ID and options for status" - QUERY=' - query($project:ID!) { - node(id: $project) { - ... on ProjectV2 { - fields(first: 100) { - nodes { - ... on ProjectV2SingleSelectField { - id - name - options { - id - name - } - } - } - } - } - } - }' - field_data=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.fields.nodes[] | select(.name == "Status")') - field_id=$(echo $field_data | jq -r '.id') - testing_option_id=$(echo $field_data | jq -r '.options[] | select(.name == "Testing") | .id') - if [ -z "$field_id" ] || [ -z "$testing_option_id" ]; then - echo "Error: Field ID or Testing option ID not found" - exit 1 - else - echo "Field ID: $field_id" - echo "Testing option ID: $testing_option_id" - echo "FIELD_ID=$field_id" >> $GITHUB_ENV - echo "TESTING_OPTION_ID=$testing_option_id" >> $GITHUB_ENV - fi - - - name: Set status to Testing - env: - GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - PROJECT_ITEM_ID: ${{ env.PROJECT_ITEM_ID }} - FIELD_ID: ${{ env.FIELD_ID }} - TESTING_OPTION_ID: ${{ env.TESTING_OPTION_ID }} - run: | - echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" - result=$(gh api graphql -f query=' - mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { - updateProjectV2ItemFieldValue(input: { - projectId: $project - itemId: $item - fieldId: $fieldId - value: { - singleSelectOptionId: $value - } - }) { - projectV2Item { - id - } - } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="${FIELD_ID}" -f value="${TESTING_OPTION_ID}") - echo "Set status result: $result" diff --git a/.github/workflows/item-complete.yml b/.github/workflows/item-complete.yml deleted file mode 100644 index c376076..0000000 --- a/.github/workflows/item-complete.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: Update Issues to Complete on Merge to Main - -on: - pull_request: - branches: - - main - types: - - closed - -jobs: - update-issues-status: - if: ${{ github.event.pull_request.merged && github.event.pull_request.head.ref == 'x' }} - runs-on: ubuntu-latest - steps: - - name: Get all issues with status "Testing" - id: get-testing-issues - env: - GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" - run: | - echo "Fetching all issues with status 'Testing'" - QUERY=' - query($project:ID!) { - node(id: $project) { - ... on ProjectV2 { - items(first: 100) { - nodes { - id - content { - ... on Issue { - number - } - } - fieldValues(first: 10) { - nodes { - ... on ProjectV2ItemFieldSingleSelectValue { - name - field { - ... on ProjectV2SingleSelectField { - name - } - } - } - } - } - } - } - } - } - }' - items=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.fieldValues.nodes[] | select(.name == "Testing")) | .id') - items=$(echo $items | tr '\n' ' ') - echo "Items with 'Testing' status: $items" - echo "TESTING_ITEMS=$items" >> $GITHUB_ENV - - - name: Get single select field ID and option ID for "Complete" - id: get-complete-option-id - env: - GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" - run: | - echo "Fetching field ID and options for status" - QUERY=' - query($project:ID!) { - node(id: $project) { - ... on ProjectV2 { - fields(first: 100) { - nodes { - ... on ProjectV2SingleSelectField { - id - name - options { - id - name - } - } - } - } - } - } - }' - field_data=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.fields.nodes[] | select(.name == "Status")') - field_id=$(echo $field_data | jq -r '.id') - complete_option_id=$(echo $field_data | jq -r '.options[] | select(.name == "Complete") | .id') - if [ -z "$field_id" ] || [ -z "$complete_option_id" ]; then - echo "Error: Field ID or Complete option ID not found" - exit 1 - else - echo "Field ID: $field_id" - echo "Complete option ID: $complete_option_id" - echo "FIELD_ID=$field_id" >> $GITHUB_ENV - echo "COMPLETE_OPTION_ID=$complete_option_id" >> $GITHUB_ENV - fi - - - name: Set status to Complete for all items - if: steps.get-testing-issues.outputs.TESTING_ITEMS != '' - env: - GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - FIELD_ID: ${{ env.FIELD_ID }} - COMPLETE_OPTION_ID: ${{ env.COMPLETE_OPTION_ID }} - TESTING_ITEMS: ${{ steps.get-testing-issues.outputs.TESTING_ITEMS }} - run: | - IFS=' ' read -ra items <<< "$TESTING_ITEMS" - for item in "${items[@]}"; do - echo "Setting status to Complete for Project Item ID: $item" - result=$(gh api graphql -f query=' - mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { - updateProjectV2ItemFieldValue(input: { - projectId: $project - itemId: $item - fieldId: $fieldId - value: { - singleSelectOptionId: $value - } - }) { - projectV2Item { - id - } - } - }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="$item" -f fieldId="${FIELD_ID}" -f value="${COMPLETE_OPTION_ID}") - echo "Set status result: $result" - done From 57e42f53e357e0e1b892b539f170961a4020991c Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Fri, 28 Jun 2024 09:48:08 +0930 Subject: [PATCH 36/36] workflow: added back workflow to add to testing --- .github/workflows/add-to-testing.yml | 117 +++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/add-to-testing.yml diff --git a/.github/workflows/add-to-testing.yml b/.github/workflows/add-to-testing.yml new file mode 100644 index 0000000..85aee45 --- /dev/null +++ b/.github/workflows/add-to-testing.yml @@ -0,0 +1,117 @@ +name: Set Issue Status to Testing on Merge to Dev + +on: + pull_request: + branches: + - dev + types: + - closed + +jobs: + update-status: + if: ${{ github.event.pull_request.merged }} + runs-on: ubuntu-latest + steps: + - name: Extract Issue Number from Branch Name + id: extract-issue-number + run: | + ISSUE_NUMBER=$(echo ${{ github.event.pull_request.head.ref }} | cut -d'-' -f1) + echo "Issue Number extracted: $ISSUE_NUMBER" + echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV + + - name: Get project item ID + id: get-project-item-id + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + run: | + echo "Fetching project item ID for issue number: $ISSUE_NUMBER" + QUERY=' + query fetchProjectItem($project: ID!) { + node(id: $project) { + ... on ProjectV2 { + items(first: 100) { + nodes { + id + content { + ... on Issue { + number + } + } + } + } + } + } + }' + item_id=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.items.nodes[] | select(.content.number == '"$ISSUE_NUMBER"') | .id') + if [ -z "$item_id" ]; then + echo "Error: Project item ID not found for issue number $ISSUE_NUMBER" + exit 1 + else + echo "Project item ID found: $item_id" + echo "PROJECT_ITEM_ID=$item_id" >> $GITHUB_ENV + fi + + - name: Get single select field ID and options + id: get-field-options + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ID: "PVT_kwDOCjbMFM4AjuUh" + run: | + echo "Fetching field ID and options for status" + QUERY=' + query($project:ID!) { + node(id: $project) { + ... on ProjectV2 { + fields(first: 100) { + nodes { + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' + field_data=$(gh api graphql -f query="$QUERY" -f project=$PROJECT_ID --jq '.data.node.fields.nodes[] | select(.name == "Status")') + field_id=$(echo $field_data | jq -r '.id') + testing_option_id=$(echo $field_data | jq -r '.options[] | select(.name == "Testing") | .id') + if [ -z "$field_id" ] || [ -z "$testing_option_id" ]; then + echo "Error: Field ID or Testing option ID not found" + exit 1 + else + echo "Field ID: $field_id" + echo "Testing option ID: $testing_option_id" + echo "FIELD_ID=$field_id" >> $GITHUB_ENV + echo "TESTING_OPTION_ID=$testing_option_id" >> $GITHUB_ENV + fi + + - name: Set status to Testing + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + PROJECT_ITEM_ID: ${{ env.PROJECT_ITEM_ID }} + FIELD_ID: ${{ env.FIELD_ID }} + TESTING_OPTION_ID: ${{ env.TESTING_OPTION_ID }} + run: | + echo "Setting status for Project Item ID: ${PROJECT_ITEM_ID}" + result=$(gh api graphql -f query=' + mutation($project:ID!, $item:ID!, $fieldId:ID!, $value:String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $fieldId + value: { + singleSelectOptionId: $value + } + }) { + projectV2Item { + id + } + } + }' -f project="PVT_kwDOCjbMFM4AjuUh" -f item="${PROJECT_ITEM_ID}" -f fieldId="${FIELD_ID}" -f value="${TESTING_OPTION_ID}") + echo "Set status result: $result"