Closed tallguyjenks closed 3 months ago
jq query to get the results from issue query to grab ID for final graph QL update
jq '.data.organization.projectV2.items.nodes[] | select(.content.number == 17) | select(.content.title | test("cca-[a-zA-Z0-9-]+-[a-zA-Z]api"))' deployment_issues.json | jq -r .content.id
This bash script could use pagination to get all items in the project to make it easier to manage with jq
# Initial cursor is empty
CURSOR=""
# Loop until all pages are fetched
while : ; do
# Execute GraphQL query
RESPONSE=$(gh api graphql -f query='
query($org: String!, $number: Int!, $cursor: String) {
organization(login: $org) {
projectV2(number: $number) {
items(first: 100, after: $cursor) {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
content {
... on Issue {
id
number
title
}
}
}
}
}
}
}' -f org="$ORGANIZATION" -F number=$PROJECT_NUMBER -f cursor="$CURSOR")
# Parse items and do something with them, e.g., append to a file
echo "$RESPONSE" | jq '.data.organization.projectV2.items.nodes[]' >> deployment_issues.json
# Check if there's a next page; if not, break the loop
HAS_NEXT_PAGE=$(echo "$RESPONSE" | jq '.data.organization.projectV2.items.pageInfo.hasNextPage')
if [ "$HAS_NEXT_PAGE" != "true" ]; then
break
fi
# Update cursor to fetch next page
CURSOR=$(echo "$RESPONSE" | jq -r '.data.organization.projectV2.items.pageInfo.endCursor')
done
echo "All items fetched successfully."
jq '. | select(.content.number == 17) | select(.content.title | test("cca-salesforce-sapi"))' deployment_issues.json
got things to start working but i had to change the secrets in the org to be available to all repositories in the org including public, but this is just temporary for testing on workflow call directly from common-devops repository.
after im done testing this reusable flow will need to be called from the pipeline which is called by the child processes and thats how the secrets get accessed. so ultimately the secrets need to be returned to their original state of private and internal repositories only.
also to pick up where i left off:
❗ the job is not liking the interpolation of the variables for the ID's to go into the query, might need separate job steps and pass the variables using github mechanisms rather than pure bash, idk, why arent the variables passing?
further work to be done on this issue:
the new fields are added and populated correctly now for the deployment issue which allows for easier sorting in the deployment dashboard pane and overall filtering is possible too by the version text field now when filtering in the search bar.
for the time being we're calling this work good, theres more that could probably be done here with custom fields but at the moment i think this work is complete.
Have to use the new graph API to access beta projects
Project ID's
related article
can use their graph api explorer and run this query to find the project ID's for the org:
Field ID's
run update operations on a given item