From bd89fd9126347aa4f3ea6aaa552d65587cdf7d2a 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 7bb2e255dd1b9be0735042922b165cf011e6c29f 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 bd21eef64706edf69fbebc9c261ab4240da97bfb 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 e9d62a9b4aa1919e7355ffa96b3bb3a05d69162f 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 da1be0ef368e6ee33c60767ef0b56c1552f834f6 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 0ad40005b4df1a4ae87d78816fbf2237731a07cc 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 1b58c1e0aa9237622b11e5c6709d87efa5279bb2 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 ca32c2cc893dc9b26bc4f6157c2b5b588b5ec14c 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 f66f2a160a3042ea8daa75756ba31515871836f3 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 72fb763c171367a9b9039ba316d187d1a256a09c 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 b9079a5f3df5000ca78c8fb9eaea3db7d215708c 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 1f0247dd78490d57ce6e3fec9a48c769413bbad8 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 5f58fc63b07a16a2ef4cd5ff4ca5f83973426cd5 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 0e772ecf385bfd9336ec6b2880187e44380d7556 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 4b67031e788ed0cb002b66e8091e11c07fc5ece5 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 757a7522e323db4c6bd82caa8d00fbb63500e78d 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 527e415d189bcc47a8faea46dea6feb961464370 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 61a363ff934c8e4530944c2fd2030211a498b52f 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 b4522aeefa5b8a2b85a4143976caa13aa4e372c6 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 175459139af33d30b1f22bb3041f932557b3a7ee 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 fdc4edbf90e1f82f1910f5ba98f6d8d5dd0041f5 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 22602f24e991d5df22eddd553eed3a77336a43cf 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 7badb3661610b3ecdf30be6aaaba31591ae41369 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 17f623a80515b15ac47f8567fec87e5199b71222 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 e471edd96fb10de70c00480990518447bf69de29 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 515e52dcfa8336d6dc1c30838b3da89702282fc9 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 14d2c288d4de152296eab36126905fcd47922cb7 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 cafc0ed796f5eb6197c0613d5ead44bf97ba8565 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 a4160941afeae448353b6bb78c01c14adc70d5eb 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 0ec65299ef64979c6a467f64fe72198749a70dc0 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 4090e5e3b9a03487a5c20f04078acd888c61c7f3 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 fe49baf40204d925cd42c91c9b552cc9d27d26c0 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 3acc743b98493832ad2544aa05782b390a7a0a13 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 c081d7d7a4e14137a334398688479723c52ab505 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 d4dc3b6c2d94144114b79d154f39164abc396bd8 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"