mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 10:51:02 +01:00
workflow: Set issue status to "Testing" on merge to dev
This commit is contained in:
117
.github/workflows/add-to-testing.yml
vendored
Normal file
117
.github/workflows/add-to-testing.yml
vendored
Normal file
@@ -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"
|
||||
Reference in New Issue
Block a user