From 7a5b0dab647d0fc0ce5d2e931e4c3f0ec32a039b Mon Sep 17 00:00:00 2001 From: Ansel Robateau Date: Tue, 3 Dec 2024 00:15:22 -0600 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20import=20missing=20sc?= =?UTF-8?q?ripts=20and=20add=20updated=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: CORE-1661 --- .../confluence-release-notes/action.yml | 13 +----- .../jira_get_ticket.sh | 43 ++++++++++++++++++ .../jira_release_notes.sh | 44 +++++++++++++++++++ 3 files changed, 88 insertions(+), 12 deletions(-) create mode 100755 .github/actions/confluence-release-notes/jira_get_ticket.sh create mode 100755 .github/actions/confluence-release-notes/jira_release_notes.sh diff --git a/.github/actions/confluence-release-notes/action.yml b/.github/actions/confluence-release-notes/action.yml index 1b9aaf4..8ab3f84 100644 --- a/.github/actions/confluence-release-notes/action.yml +++ b/.github/actions/confluence-release-notes/action.yml @@ -31,19 +31,8 @@ runs: REPOSITORY_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) RELEASE_NAME=$(echo $REPOSITORY_NAME-v$VERSION) echo "RELEASE_NAME=$RELEASE_NAME" - JQL="fixVersion = $RELEASE_NAME" - ${{ github.action_path }}/jira_find_tickets.sh "$JQL" > jira_tickets.json - echo "*** JIRA Tickets ***" - cat jira_tickets.json - node ${{ github.action_path }}/generate_release_notes.js jira_tickets.json ${{ github.action_path }}/release_notes.html - echo "*** Release Notes ***" - cat ${{ github.action_path }}/release_notes.html - YEAR=$(date +'%Y') DATE=$(date +'%Y-%m-%d') - ${{ github.action_path }}/confluence_create_release_page.sh "$YEAR" "$RELEASE_NAME" "$DATE" ${{ github.action_path }}/release_notes.html > results.json - echo "*** Results ***" - cat results.json - jq -r '"\(.["_links"].base)\(.["_links"].webui)"' results.json + ${{ github.action_path }}/jira_release_notes.sh "$RELEASE_NAME" "$DATE" env: VERSION: ${{ inputs.version }} JIRA_USERNAME: ${{ inputs.jira-username }} diff --git a/.github/actions/confluence-release-notes/jira_get_ticket.sh b/.github/actions/confluence-release-notes/jira_get_ticket.sh new file mode 100755 index 0000000..65f195f --- /dev/null +++ b/.github/actions/confluence-release-notes/jira_get_ticket.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +JIRA_CONFIG="$($SCRIPT_DIR/jira_get_config.sh)" + +TOKEN=$(echo $JIRA_CONFIG | jq -r .auth.token) +USERNAME=$(echo $JIRA_CONFIG | jq -r .auth.user) +JIRA_DOMAIN=$(echo $JIRA_CONFIG | jq -r .jira.domain) + +if [ "$CURL_CMD" == "" ]; then + CURL_CMD="$(which curl)" +fi + +if [ "$JIRA_DOMAIN" == "" ] || [ "$JIRA_DOMAIN" == "null" ]; then + echo "Please set the jira domain in the config file" + exit +fi + +if [ "$1" == "" ]; then + echo "Usage: [ticket id] (option)" + echo " options:" + echo " --history -h: show usage history" + echo " --links -l: show web links" + exit 1 +fi + +if [ "$2" == "--history" ] || [ "$2" == "-h" ]; then + EXPAND="?expand=changelog" +elif [ "$2" == "--links" ] || [ "$2" == "-l" ]; then + EXPAND="/remotelink" +else + EXPAND= +fi + +TICKET_ID=$1 + +TICKET_INFO=$($CURL_CMD \ + -X GET \ + --user ${USERNAME}:${TOKEN} \ + -H "Content-Type: application/json" \ + "https://$JIRA_DOMAIN.atlassian.net/rest/api/2/issue/$TICKET_ID$EXPAND" 2>/dev/null) + +echo $TICKET_INFO | jq . diff --git a/.github/actions/confluence-release-notes/jira_release_notes.sh b/.github/actions/confluence-release-notes/jira_release_notes.sh new file mode 100755 index 0000000..84addd2 --- /dev/null +++ b/.github/actions/confluence-release-notes/jira_release_notes.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -e +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function usage { + echo "Usage: [fixVersion] [releaseDate: YYYY-MM-DD]" + exit 1 +} + +function validate_input { + if [ -z "$1" ] || [ -z "$2" ]; then + usage + fi + if [ ! "$2" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]; then + usage + fi +} + +function main { + local fixVersion=$1 + local releaseDate=$2 + echo "RELEASE_NAME=$fixVersion" + JQL="fixVersion = $fixVersion" + local jira_ticket_file=$(mktemp) + $SCRIPT_DIR/jira_find_tickets.sh "$JQL" > $jira_ticket_file + echo "*** JIRA Tickets ***" + cat $jira_ticket_file + local release_notes_file=$(mktemp) + node $SCRIPT_DIR/generate_release_notes.js $jira_ticket_file $release_notes_file + echo "*** Release Notes ***" + cat $release_notes_file + YEAR=$(echo $releaseDate | cut -d'-' -f1) + DATE=$releaseDate + local results_file=$(mktemp) + bash $SCRIPT_DIR/confluence_create_release_page.sh "$YEAR" "$fixVersion" "$DATE" $release_notes_file > $results_file + echo "*** Results ***" + cat $results_file + jq -r '"\(.["_links"].base)\(.["_links"].webui)"' $results_file +} + +validate_input "$1" "$2" +main "$1" "$2" +exit $? \ No newline at end of file From 8c476350c435678f4895fa303b0ef98299a63146 Mon Sep 17 00:00:00 2001 From: Ansel Robateau Date: Tue, 3 Dec 2024 00:34:57 -0600 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20update=20the=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: CORE-1661 --- .github/actions/confluence-release-notes/jira_get_ticket.sh | 2 +- .github/actions/confluence-release-notes/jira_release_notes.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/confluence-release-notes/jira_get_ticket.sh b/.github/actions/confluence-release-notes/jira_get_ticket.sh index 65f195f..254ac47 100755 --- a/.github/actions/confluence-release-notes/jira_get_ticket.sh +++ b/.github/actions/confluence-release-notes/jira_get_ticket.sh @@ -38,6 +38,6 @@ TICKET_INFO=$($CURL_CMD \ -X GET \ --user ${USERNAME}:${TOKEN} \ -H "Content-Type: application/json" \ - "https://$JIRA_DOMAIN.atlassian.net/rest/api/2/issue/$TICKET_ID$EXPAND" 2>/dev/null) + "https://$JIRA_DOMAIN/rest/api/2/issue/$TICKET_ID$EXPAND" 2>/dev/null) echo $TICKET_INFO | jq . diff --git a/.github/actions/confluence-release-notes/jira_release_notes.sh b/.github/actions/confluence-release-notes/jira_release_notes.sh index 84addd2..9a4168f 100755 --- a/.github/actions/confluence-release-notes/jira_release_notes.sh +++ b/.github/actions/confluence-release-notes/jira_release_notes.sh @@ -12,7 +12,7 @@ function validate_input { if [ -z "$1" ] || [ -z "$2" ]; then usage fi - if [ ! "$2" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]; then + if [[ ! "$2" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then usage fi }