Skip to content

Commit

Permalink
chore: tbs
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaklygin committed Jul 12, 2023
1 parent 653cd95 commit ec32988
Showing 1 changed file with 45 additions and 97 deletions.
142 changes: 45 additions & 97 deletions .github/workflows/test-jira-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,107 +55,55 @@ jobs:
exit 0
fi
# JSON_PAYLOAD=$(jq -cn '
# {
# query: $query,
# variables: {
# "repoOwner": $repoOwnerVar,
# "repoName": $repoNameVar,
# "numCommits": $numCommitsVar,
# "headRef": $headRefVar
# }
# }' \
# --arg query '
# query ($repoOwner: String!, $repoName: String!, $headRef: String!, $numCommits: Int!) {
# repository(name: $repoName, owner: $repoOwner) {
# commit: object(expression: $headRef) {
# ... on Commit {
# history(first: $numCommits) {
# pageInfo {
# hasNextPage
# startCursor
# endCursor
# }
# nodes {
# associatedPullRequests(first: 100) {
# nodes {
# title
# bodyText
# }
# }
# }
# }
# }
# }
# }
# }' \
# --arg repoOwnerVar "$OWNER" \
# --arg repoNameVar "$REPO" \
# --argjson numCommitsVar ${NUMCOMMITS} \
# --arg headRefVar "$HEAD_REF")
# # RESPONSE=$(curl --silent --json @- \
# # -H "Authorization: Bearer ${GITHUB_TOKEN}" \
# # https://api.github.com/graphql \
# # -d "$JSON_PAYLOAD")
# RESPONSE=$(curl --silent -H "Authorization: Bearer ${GITHUB_TOKEN}" \
# -H "Content-Type: application/json" \
# https://api.github.com/graphql \
# -d "$JSON_PAYLOAD")
# echo "$RESPONSE"
# JIRA_KEYS=$(echo "$RESPONSE" | jq -c '[ .data.repository.commit.history.nodes[].associatedPullRequests.nodes[] | [.title, .bodyText] ]?
# | flatten
# | map(capture("^\\[(?<jirakey>[A-Z]{2,}-[0-9]+)\\]"))
# | map(.jirakey)
# | unique')
JIRA_KEYS=$(jq -cn '
{
query: $query,
variables: {
"repoOwner": $repoOwnerVar,
"repoName": $repoNameVar,
"numCommits": $numCommitsVar,
"headRef": $headRefVar
}
}' \
--arg query '
query ($repoOwner: String!, $repoName: String!, $headRef: String!, $numCommits: Int!) {
repository(name: $repoName, owner: $repoOwner) {
commit: object(expression: $headRef) {
... on Commit {
history(first: $numCommits) {
pageInfo {
hasNextPage
startCursor
endCursor
}
nodes {
associatedPullRequests(first: 100) {
nodes {
title
bodyText
JSON_PAYLOAD=$(jq -cn '
{
query: $query,
variables: {
"repoOwner": $repoOwnerVar,
"repoName": $repoNameVar,
"numCommits": $numCommitsVar,
"headRef": $headRefVar
}
}' \
--arg query '
query ($repoOwner: String!, $repoName: String!, $headRef: String!, $numCommits: Int!) {
repository(name: $repoName, owner: $repoOwner) {
commit: object(expression: $headRef) {
... on Commit {
history(first: $numCommits) {
pageInfo {
hasNextPage
startCursor
endCursor
}
nodes {
associatedPullRequests(first: 100) {
nodes {
title
body
}
}
}
}
}
}
}
}
}
}
}
}' \
--arg repoOwnerVar "$OWNER" \
--arg repoNameVar "$REPO" \
--argjson numCommitsVar ${NUMCOMMITS} \
--arg headRefVar "$HEADREF" |
curl --silent --json @- \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
https://api.github.com/graphql |
jq -c '[ .data.repository.commit.history.nodes[].associatedPullRequests.nodes[] | [.title, .bodyText] ]?
| flatten
| map(capture("^\\[(?<jirakey>[A-Z]{2,}-[0-9]+)\\]"))
| map(.jirakey)
| unique')
}' \
--arg repoOwnerVar "$OWNER" \
--arg repoNameVar "$REPO" \
--argjson numCommitsVar ${NUMCOMMITS} \
--arg headRefVar "$HEAD_REF")
RESPONSE=$(curl --silent -H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
https://api.github.com/graphql \
-d "$JSON_PAYLOAD")
echo "$RESPONSE"
JIRA_KEYS=$(echo "$RESPONSE" | jq -c '[ .data.repository.commit.history.nodes[].associatedPullRequests.nodes[] | [.title, .body] ]?
| flatten
| map(capture("^\\[(?<jirakey>[A-Z]{2,}-[0-9]+)\\]"))
| map(.jirakey)
| unique')
# Send deployment info to JIRA
if [ -n "$JIRA_KEYS" ]; then
Expand Down

0 comments on commit ec32988

Please sign in to comment.