Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaangiolillo committed Oct 23, 2024
1 parent 9ebf202 commit 64a240e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 10 additions & 8 deletions .github/scripts/create_jira_ticket.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ set -eou pipefail

url_encode() {
local string="$1"
printf '%s' "$string" | xxd -p | sed 's/\(..\)/%\1/g'
local encoded=""
encoded=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''$string'''))")
echo "$encoded"
}

encoded_jira_ticket_title=$(url_encode "${JIRA_TICKET_TITLE:?}")
echo "${encoded_jira_ticket_title}"

found_issue=$(curl --request GET \
--url 'https://jira.mongodb.org/rest/api/2/search?jql=project=10984%20AND%20issuetype=12%20AND%20component=35986%20AND%20summary~'"${encoded_jira_ticket_title:?}" \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN:?}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' | jq .total)
--url 'https://jira.mongodb.org/rest/api/2/search?jql=project=10984%20AND%20issuetype=12%20AND%20component=35986%20AND%20summary~"'"${encoded_jira_ticket_title:?}"'"' \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN:?}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' | jq .total)

if [ "$found_issue" -ne 0 ]; then
echo "There is already a Jira ticket with the title ${JIRA_TICKET_TITLE:?}"
echo "No new Jira ticket will be created"
echo "There is already a Jira ticket with the title \"${JIRA_TICKET_TITLE:?}\""
echo "No new Jira ticket will be created."
exit 0
fi

Expand All @@ -47,7 +49,7 @@ json_response=$(curl --request POST \
},
"customfield_12751": [{
"id": "22223"
}],
}],
"description": "'"${JIRA_TICKET_DESCRIPTION:?}"'",
"components": [
{
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/api-versions-reminder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
with:
sparse-checkout:
.github/scripts/upcoming_api_releases.sh

- name: Install Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
with:
python-version: '3.12'

- name: Check if there are upcoming API versions releases
id: check-api-versions
run: .github/scripts/upcoming_api_releases.sh
Expand All @@ -28,6 +34,7 @@ jobs:
JIRA_TICKET_DESCRIPTION: "The following API Versions are scheduled to be released in the next 3 weeks: ${{steps.check-api-versions.outputs.api_versions}}"
run: .github/scripts/create_jira_ticket.sh

# Send Slack notification only if the Jira ticket was created
- name: Send Slack Notification
if: steps.create-jira-ticket.outputs.jira-ticket-id != null
env:
Expand Down

0 comments on commit 64a240e

Please sign in to comment.