From c14429756e97780575153fb71e2923799e35932b Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 3 Oct 2024 13:42:04 +1000 Subject: [PATCH 01/61] rough jira noti --- .github/workflows/run_e2e_fe.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/run_e2e_fe.yml b/.github/workflows/run_e2e_fe.yml index 4888101e..df582937 100644 --- a/.github/workflows/run_e2e_fe.yml +++ b/.github/workflows/run_e2e_fe.yml @@ -171,6 +171,17 @@ jobs: ) ) ) + always() && + ( + inputs.slack_notify == 'always' || + ( + inputs.slack_notify == 'release_only' && + ( + startsWith(github.ref_name, 'release/') || + contains(fromJSON('["uat", "master", "standby", "production"]'), github.ref_name) + ) + ) + ) needs: [run_e2e_fe] secrets: inherit with: From b958d695dc2ab6ce6bf75fc8b648fa2f4ff313f1 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 3 Oct 2024 13:42:17 +1000 Subject: [PATCH 02/61] rough jira noti --- .github/workflows/notify_jira.yml | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/notify_jira.yml diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml new file mode 100644 index 00000000..af555460 --- /dev/null +++ b/.github/workflows/notify_jira.yml @@ -0,0 +1,54 @@ +name: notify_jira + +on: + workflow_call: + inputs: + be_url: + type: string + required: true + fe_url: + type: string + required: false + default: "" + jira_id: + type: string + required: true + default: "" + status: + type: string + required: true + default: "" + workflow_link: + type: string + required: true + default: "" + +jobs: + send_e2e_result_jira: + name: send_e2e_result_jira + runs-on: ubuntu-latest + if: always() + steps: + - name: Prepare JIRA Comment + env: + BE_BASE_URL: ${{ inputs.be_url }} + FE_BASE_URL: ${{ inputs.fe_url }} + JIRA_ID: ${{ inputs.jira_id }} + WORKFLOW_LINK: ${{ inputs.workflow_link }} + STATUS: ${{ inputs.status }} + JIRA_USER: ${{ secrets.JIRA_USER }} # Secret containing JIRA username + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} # Secret containing JIRA API token + run: | + echo "Preparing JIRA comment..." + + # Determine the branch name from the Git reference + GIT_BRANCH=${GITHUB_REF##*/} + + # Construct the comment template + COMMENT="GHA: E2E Test - ${STATUS} on (this is the git branch: ${GIT_BRANCH})\n" + COMMENT+="BE URL: $BE_BASE_URL\n" + COMMENT+="FE URL: $FE_BASE_URL\n" + COMMENT+="Workflow URL: $WORKFLOW_LINK" + + # Print the comment to the console (for debugging) + echo -e "$COMMENT" From 332564cfe13982ec7d9ce971bc7a74825c577f62 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Tue, 22 Oct 2024 14:42:58 +1100 Subject: [PATCH 03/61] test --- .github/workflows/notify_jira.yml | 120 +++++++++++++++++++++++------- 1 file changed, 92 insertions(+), 28 deletions(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index af555460..0db9b752 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -3,17 +3,6 @@ name: notify_jira on: workflow_call: inputs: - be_url: - type: string - required: true - fe_url: - type: string - required: false - default: "" - jira_id: - type: string - required: true - default: "" status: type: string required: true @@ -24,31 +13,106 @@ on: default: "" jobs: - send_e2e_result_jira: - name: send_e2e_result_jira + notify_jira: runs-on: ubuntu-latest - if: always() steps: + - name: Extract JIRA ID from the commit message + id: extract_jira_id + run: | + # Fetch commit message from the GitHub API + commit_info=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) + + commit_message=$(echo "$commit_info" | jq -r '.commit.message') + + # Extract JIRA ID (return code handling) + JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}') + if [ $? -ne 0 ] || [ -z "$JIRA_ID" ]; then + echo "No JIRA ID found in commit message, skipping steps." + echo "JIRA_ID_NOT_FOUND=true" >> $GITHUB_ENV + exit 0 # Exit gracefully without failing the job + else + echo "Extracted JIRA ID: $JIRA_ID" + echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV + fi + + - name: Determine the workflow status + id: determine_e2e_status + if: success() && env.JIRA_ID != '' + env: + JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID + run: | + STATUS="success" + echo "fe_smoke status: ${{ needs.fe_smoke.result }}" + echo "fe_core_visual status: ${{ needs.fe_core_visual.result }}" + echo "fe_custom_visual status: ${{ needs.fe_custom_visual.result }}" + echo "fe_custom status: ${{ needs.fe_custom.result }}" + echo "fe_core status: ${{ needs.fe_core.result }}" + + if [[ "${{ needs.fe_smoke.result }}" == "failure" ]] || \ + [[ "${{ needs.fe_core_visual.result }}" == "failure" ]] || \ + [[ "${{ needs.fe_custom_visual.result }}" == "failure" ]] || \ + [[ "${{ needs.fe_custom.result }}" == "failure" ]] || \ + [[ "${{ needs.fe_core.result }}" == "failure" ]]; then + STATUS="failure" + fi + + echo "Overall workflow status: $STATUS" + echo "STATUS=$STATUS" >> $GITHUB_ENV + - name: Prepare JIRA Comment + id: prepare_jira_comment + if: success() && env.JIRA_ID != '' env: - BE_BASE_URL: ${{ inputs.be_url }} - FE_BASE_URL: ${{ inputs.fe_url }} - JIRA_ID: ${{ inputs.jira_id }} - WORKFLOW_LINK: ${{ inputs.workflow_link }} - STATUS: ${{ inputs.status }} - JIRA_USER: ${{ secrets.JIRA_USER }} # Secret containing JIRA username - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} # Secret containing JIRA API token + JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID + WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run + STATUS: ${{ env.STATUS }} # Use the extracted STATUS run: | echo "Preparing JIRA comment..." - + # Determine the branch name from the Git reference GIT_BRANCH=${GITHUB_REF##*/} - + # Construct the comment template - COMMENT="GHA: E2E Test - ${STATUS} on (this is the git branch: ${GIT_BRANCH})\n" - COMMENT+="BE URL: $BE_BASE_URL\n" - COMMENT+="FE URL: $FE_BASE_URL\n" + COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" COMMENT+="Workflow URL: $WORKFLOW_LINK" - # Print the comment to the console (for debugging) - echo -e "$COMMENT" + # Print the comment to the console for debugging + echo -e "COMMENT:\n${COMMENT}" + echo "COMMENT=$COMMENT" >> $GITHUB_ENV + + - name: Post JIRA Comment + id: post_jira_comment + if: success() && env.JIRA_ID != '' + env: + JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID from the commit message + JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} # Jira username from secrets + JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} # Jira password from secrets + COMMENT: ${{ env.COMMENT }} # The comment prepared in the previous step + run: | + echo -e "${JIRA_ID}" + + # Define the JIRA comment API endpoint + JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${JIRA_ID}/comment" + + # Post the comment to JIRA using basic auth with username and password + response=$(curl -s -w "%{http_code}" -X POST \ + -H "Content-Type: application/json" \ + -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ + --data "{\"body\": \"${COMMENT}\"}" \ + "${JIRA_API_URL}") + + http_code="${response:(-3)}" # Extract HTTP status code (last 3 characters) + response_body="${response:0:-3}" # The response body + + # Handle the API response + if [ "$http_code" -eq 201 ]; then + echo "Comment posted successfully to Jira issue ${JIRA_ID}" + elif [ "$http_code" -eq 404 ]; then + echo "Jira issue ${JIRA_ID} not found. No comment posted." + else + echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" + echo "Response Body: $response_body" + fi From d98c6849baf9a963b00b8e2cfea8a9a27fba84b3 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Tue, 22 Oct 2024 14:45:08 +1100 Subject: [PATCH 04/61] test --- .github/workflows/notify_jira.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 0db9b752..64495996 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -3,10 +3,6 @@ name: notify_jira on: workflow_call: inputs: - status: - type: string - required: true - default: "" workflow_link: type: string required: true From 85a4420139fb22e4e7b75d7cd34bc4f18291511f Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Tue, 22 Oct 2024 17:32:59 +1100 Subject: [PATCH 05/61] test --- .github/workflows/notify_jira.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 64495996..2ebb30dd 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -21,6 +21,8 @@ jobs: -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) + echo "Commit API response: $commit_info" + commit_message=$(echo "$commit_info" | jq -r '.commit.message') # Extract JIRA ID (return code handling) From 46f756243bca0bdcd7c0b5d103785dd8c21df6c9 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 10:04:10 +1100 Subject: [PATCH 06/61] removed unused --- .github/workflows/run_e2e_fe.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/run_e2e_fe.yml b/.github/workflows/run_e2e_fe.yml index df582937..4888101e 100644 --- a/.github/workflows/run_e2e_fe.yml +++ b/.github/workflows/run_e2e_fe.yml @@ -171,17 +171,6 @@ jobs: ) ) ) - always() && - ( - inputs.slack_notify == 'always' || - ( - inputs.slack_notify == 'release_only' && - ( - startsWith(github.ref_name, 'release/') || - contains(fromJSON('["uat", "master", "standby", "production"]'), github.ref_name) - ) - ) - ) needs: [run_e2e_fe] secrets: inherit with: From 9d9cae6430908eb2acf53365aaf886053833c34c Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 10:36:21 +1100 Subject: [PATCH 07/61] test --- .github/workflows/notify_jira.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 2ebb30dd..662664fa 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -7,6 +7,10 @@ on: type: string required: true default: "" + status: + type: string + required: true + default: "" jobs: notify_jira: @@ -48,6 +52,7 @@ jobs: echo "fe_custom_visual status: ${{ needs.fe_custom_visual.result }}" echo "fe_custom status: ${{ needs.fe_custom.result }}" echo "fe_core status: ${{ needs.fe_core.result }}" + echo "status: $WORKFLOW_LINK" if [[ "${{ needs.fe_smoke.result }}" == "failure" ]] || \ [[ "${{ needs.fe_core_visual.result }}" == "failure" ]] || \ From b81dad30cd40f008cd546060f2b75988f2e833bf Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 11:29:26 +1100 Subject: [PATCH 08/61] test --- .github/workflows/notify_jira.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 662664fa..6a8864ab 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -25,13 +25,13 @@ jobs: -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) - echo "Commit API response: $commit_info" - commit_message=$(echo "$commit_info" | jq -r '.commit.message') - # Extract JIRA ID (return code handling) + # Extract JIRA ID JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}') - if [ $? -ne 0 ] || [ -z "$JIRA_ID" ]; then + + # Check if JIRA ID is found + if [ -z "$JIRA_ID" ]; then echo "No JIRA ID found in commit message, skipping steps." echo "JIRA_ID_NOT_FOUND=true" >> $GITHUB_ENV exit 0 # Exit gracefully without failing the job From a7bbbf7d8bcf4f03529541c12cb421cb4436350c Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 11:43:31 +1100 Subject: [PATCH 09/61] test --- .github/workflows/notify_jira.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 6a8864ab..1d7955c2 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -45,14 +45,14 @@ jobs: if: success() && env.JIRA_ID != '' env: JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID + STATUS: ${{ inputs.status }} run: | - STATUS="success" echo "fe_smoke status: ${{ needs.fe_smoke.result }}" echo "fe_core_visual status: ${{ needs.fe_core_visual.result }}" echo "fe_custom_visual status: ${{ needs.fe_custom_visual.result }}" echo "fe_custom status: ${{ needs.fe_custom.result }}" echo "fe_core status: ${{ needs.fe_core.result }}" - echo "status: $WORKFLOW_LINK" + echo "status: $STATUS" if [[ "${{ needs.fe_smoke.result }}" == "failure" ]] || \ [[ "${{ needs.fe_core_visual.result }}" == "failure" ]] || \ From a6c72ca55e6cb055d9e266f8ad00d7763a6bb0de Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 12:50:15 +1100 Subject: [PATCH 10/61] test --- .github/workflows/notify_jira.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 1d7955c2..87842418 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -25,6 +25,12 @@ jobs: -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) + # Check if curl was successful + if [ $? -ne 0 ]; then + echo "Failed to fetch commit message." + exit 0 # Exit gracefully on curl failure + fi + commit_message=$(echo "$commit_info" | jq -r '.commit.message') # Extract JIRA ID From c8fb1faf5809d8b00f87b1df8b5700b3fff71a45 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 13:15:37 +1100 Subject: [PATCH 11/61] noid --- .github/workflows/notify_jira.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 87842418..f90de3c4 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -25,26 +25,31 @@ jobs: -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) - # Check if curl was successful - if [ $? -ne 0 ]; then + # Check if curl was successful + if [ $? -ne 0 ]; then echo "Failed to fetch commit message." exit 0 # Exit gracefully on curl failure fi - + + echo "Commit API response: $commit_info" + commit_message=$(echo "$commit_info" | jq -r '.commit.message') - + + echo "Commit message: $commit_message" + # Extract JIRA ID - JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}') - + JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code + # Check if JIRA ID is found if [ -z "$JIRA_ID" ]; then - echo "No JIRA ID found in commit message, skipping steps." + echo "No JIRA ID found in commit message: $commit_message" echo "JIRA_ID_NOT_FOUND=true" >> $GITHUB_ENV exit 0 # Exit gracefully without failing the job else echo "Extracted JIRA ID: $JIRA_ID" echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV fi + - name: Determine the workflow status id: determine_e2e_status From d3e5dac3ba58696613260d262aebd95106c0ec0f Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 13:32:50 +1100 Subject: [PATCH 12/61] test --- .github/workflows/notify_jira.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index f90de3c4..3276bce2 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -3,10 +3,10 @@ name: notify_jira on: workflow_call: inputs: - workflow_link: - type: string - required: true - default: "" + # workflow_link: + # type: string + # required: true + # default: "" status: type: string required: true @@ -30,12 +30,8 @@ jobs: echo "Failed to fetch commit message." exit 0 # Exit gracefully on curl failure fi - - echo "Commit API response: $commit_info" - + commit_message=$(echo "$commit_info" | jq -r '.commit.message') - - echo "Commit message: $commit_message" # Extract JIRA ID JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code @@ -43,7 +39,6 @@ jobs: # Check if JIRA ID is found if [ -z "$JIRA_ID" ]; then echo "No JIRA ID found in commit message: $commit_message" - echo "JIRA_ID_NOT_FOUND=true" >> $GITHUB_ENV exit 0 # Exit gracefully without failing the job else echo "Extracted JIRA ID: $JIRA_ID" @@ -90,7 +85,7 @@ jobs: GIT_BRANCH=${GITHUB_REF##*/} # Construct the comment template - COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" + COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}, ID: ${JIRA_ID}\n" COMMENT+="Workflow URL: $WORKFLOW_LINK" # Print the comment to the console for debugging From e5acf58325a4ee5f04d1bd1efe47ddf08c674909 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 14:18:56 +1100 Subject: [PATCH 13/61] test --- .github/workflows/notify_jira.yml | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 3276bce2..247703d7 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -3,10 +3,6 @@ name: notify_jira on: workflow_call: inputs: - # workflow_link: - # type: string - # required: true - # default: "" status: type: string required: true @@ -52,22 +48,7 @@ jobs: env: JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID STATUS: ${{ inputs.status }} - run: | - echo "fe_smoke status: ${{ needs.fe_smoke.result }}" - echo "fe_core_visual status: ${{ needs.fe_core_visual.result }}" - echo "fe_custom_visual status: ${{ needs.fe_custom_visual.result }}" - echo "fe_custom status: ${{ needs.fe_custom.result }}" - echo "fe_core status: ${{ needs.fe_core.result }}" - echo "status: $STATUS" - - if [[ "${{ needs.fe_smoke.result }}" == "failure" ]] || \ - [[ "${{ needs.fe_core_visual.result }}" == "failure" ]] || \ - [[ "${{ needs.fe_custom_visual.result }}" == "failure" ]] || \ - [[ "${{ needs.fe_custom.result }}" == "failure" ]] || \ - [[ "${{ needs.fe_core.result }}" == "failure" ]]; then - STATUS="failure" - fi - + run: echo "Overall workflow status: $STATUS" echo "STATUS=$STATUS" >> $GITHUB_ENV @@ -77,7 +58,7 @@ jobs: env: JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run - STATUS: ${{ env.STATUS }} # Use the extracted STATUS + STATUS: ${{ env.STATUS }} run: | echo "Preparing JIRA comment..." @@ -85,7 +66,7 @@ jobs: GIT_BRANCH=${GITHUB_REF##*/} # Construct the comment template - COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}, ID: ${JIRA_ID}\n" + COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" COMMENT+="Workflow URL: $WORKFLOW_LINK" # Print the comment to the console for debugging From d7b08b978ff16b9b85e996dcf8a6243adcf33473 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 14:30:56 +1100 Subject: [PATCH 14/61] test --- .github/workflows/notify_jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 247703d7..de311af7 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -48,7 +48,7 @@ jobs: env: JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID STATUS: ${{ inputs.status }} - run: + run: | echo "Overall workflow status: $STATUS" echo "STATUS=$STATUS" >> $GITHUB_ENV From c6f8eddf7d81adf431c9ee38e6ebb900b2f31b83 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 14:51:58 +1100 Subject: [PATCH 15/61] test id not exist --- .github/workflows/notify_jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index de311af7..5d5a04c4 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -85,7 +85,7 @@ jobs: echo -e "${JIRA_ID}" # Define the JIRA comment API endpoint - JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${JIRA_ID}/comment" + JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${SCFA-11111}/comment" # Post the comment to JIRA using basic auth with username and password response=$(curl -s -w "%{http_code}" -X POST \ From 3a31112f7890bde8c755bd5a88b1822b1c23dc3e Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 14:52:58 +1100 Subject: [PATCH 16/61] test --- .github/workflows/notify_jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index 5d5a04c4..de311af7 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -85,7 +85,7 @@ jobs: echo -e "${JIRA_ID}" # Define the JIRA comment API endpoint - JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${SCFA-11111}/comment" + JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${JIRA_ID}/comment" # Post the comment to JIRA using basic auth with username and password response=$(curl -s -w "%{http_code}" -X POST \ From a598c8d1ba714dbde92056d1843ba2512c946aba Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 15:17:52 +1100 Subject: [PATCH 17/61] cleanup --- .github/workflows/notify_jira.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml index de311af7..4fc03632 100644 --- a/.github/workflows/notify_jira.yml +++ b/.github/workflows/notify_jira.yml @@ -46,7 +46,7 @@ jobs: id: determine_e2e_status if: success() && env.JIRA_ID != '' env: - JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID + JIRA_ID: ${{ env.JIRA_ID }} STATUS: ${{ inputs.status }} run: | echo "Overall workflow status: $STATUS" @@ -56,7 +56,7 @@ jobs: id: prepare_jira_comment if: success() && env.JIRA_ID != '' env: - JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID + JIRA_ID: ${{ env.JIRA_ID }} WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run STATUS: ${{ env.STATUS }} run: | From 9fcbeb90de9058cdf1702c646957db24c34cd090 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 16:06:28 +1100 Subject: [PATCH 18/61] rename --- .github/workflows/notify_jira.yml | 108 ------------------------------ 1 file changed, 108 deletions(-) delete mode 100644 .github/workflows/notify_jira.yml diff --git a/.github/workflows/notify_jira.yml b/.github/workflows/notify_jira.yml deleted file mode 100644 index 4fc03632..00000000 --- a/.github/workflows/notify_jira.yml +++ /dev/null @@ -1,108 +0,0 @@ -name: notify_jira - -on: - workflow_call: - inputs: - status: - type: string - required: true - default: "" - -jobs: - notify_jira: - runs-on: ubuntu-latest - steps: - - name: Extract JIRA ID from the commit message - id: extract_jira_id - run: | - # Fetch commit message from the GitHub API - commit_info=$(curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) - - # Check if curl was successful - if [ $? -ne 0 ]; then - echo "Failed to fetch commit message." - exit 0 # Exit gracefully on curl failure - fi - - commit_message=$(echo "$commit_info" | jq -r '.commit.message') - - # Extract JIRA ID - JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code - - # Check if JIRA ID is found - if [ -z "$JIRA_ID" ]; then - echo "No JIRA ID found in commit message: $commit_message" - exit 0 # Exit gracefully without failing the job - else - echo "Extracted JIRA ID: $JIRA_ID" - echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV - fi - - - - name: Determine the workflow status - id: determine_e2e_status - if: success() && env.JIRA_ID != '' - env: - JIRA_ID: ${{ env.JIRA_ID }} - STATUS: ${{ inputs.status }} - run: | - echo "Overall workflow status: $STATUS" - echo "STATUS=$STATUS" >> $GITHUB_ENV - - - name: Prepare JIRA Comment - id: prepare_jira_comment - if: success() && env.JIRA_ID != '' - env: - JIRA_ID: ${{ env.JIRA_ID }} - WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run - STATUS: ${{ env.STATUS }} - run: | - echo "Preparing JIRA comment..." - - # Determine the branch name from the Git reference - GIT_BRANCH=${GITHUB_REF##*/} - - # Construct the comment template - COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" - COMMENT+="Workflow URL: $WORKFLOW_LINK" - - # Print the comment to the console for debugging - echo -e "COMMENT:\n${COMMENT}" - echo "COMMENT=$COMMENT" >> $GITHUB_ENV - - - name: Post JIRA Comment - id: post_jira_comment - if: success() && env.JIRA_ID != '' - env: - JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID from the commit message - JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} # Jira username from secrets - JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} # Jira password from secrets - COMMENT: ${{ env.COMMENT }} # The comment prepared in the previous step - run: | - echo -e "${JIRA_ID}" - - # Define the JIRA comment API endpoint - JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${JIRA_ID}/comment" - - # Post the comment to JIRA using basic auth with username and password - response=$(curl -s -w "%{http_code}" -X POST \ - -H "Content-Type: application/json" \ - -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ - --data "{\"body\": \"${COMMENT}\"}" \ - "${JIRA_API_URL}") - - http_code="${response:(-3)}" # Extract HTTP status code (last 3 characters) - response_body="${response:0:-3}" # The response body - - # Handle the API response - if [ "$http_code" -eq 201 ]; then - echo "Comment posted successfully to Jira issue ${JIRA_ID}" - elif [ "$http_code" -eq 404 ]; then - echo "Jira issue ${JIRA_ID} not found. No comment posted." - else - echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" - echo "Response Body: $response_body" - fi From e4801c894df16186acab34a7574742129b2113ab Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 23 Oct 2024 16:06:40 +1100 Subject: [PATCH 19/61] rename --- .github/workflows/test_notify_jira.yml | 108 +++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/test_notify_jira.yml diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml new file mode 100644 index 00000000..94a4c06c --- /dev/null +++ b/.github/workflows/test_notify_jira.yml @@ -0,0 +1,108 @@ +name: test_notify_jira + +on: + workflow_call: + inputs: + status: + type: string + required: true + default: "" + +jobs: + notify_jira: + runs-on: ubuntu-latest + steps: + - name: Extract JIRA ID from the commit message + id: extract_jira_id + run: | + # Fetch commit message from the GitHub API + commit_info=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) + + # Check if curl was successful + if [ $? -ne 0 ]; then + echo "Failed to fetch commit message." + exit 0 # Exit gracefully on curl failure + fi + + commit_message=$(echo "$commit_info" | jq -r '.commit.message') + + # Extract JIRA ID + JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code + + # Check if JIRA ID is found + if [ -z "$JIRA_ID" ]; then + echo "No JIRA ID found in commit message: $commit_message" + exit 0 # Exit gracefully without failing the job + else + echo "Extracted JIRA ID: $JIRA_ID" + echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV + fi + + + - name: Determine the workflow status + id: determine_e2e_status + if: success() && env.JIRA_ID != '' + env: + JIRA_ID: ${{ env.JIRA_ID }} + STATUS: ${{ inputs.status }} + run: | + echo "Overall workflow status: $STATUS" + echo "STATUS=$STATUS" >> $GITHUB_ENV + + - name: Prepare JIRA Comment + id: prepare_jira_comment + if: success() && env.JIRA_ID != '' + env: + JIRA_ID: ${{ env.JIRA_ID }} + WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run + STATUS: ${{ env.STATUS }} + run: | + echo "Preparing JIRA comment..." + + # Determine the branch name from the Git reference + GIT_BRANCH=${GITHUB_REF##*/} + + # Construct the comment template + COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" + COMMENT+="Workflow URL: $WORKFLOW_LINK" + + # Print the comment to the console for debugging + echo -e "COMMENT:\n${COMMENT}" + echo "COMMENT=$COMMENT" >> $GITHUB_ENV + + - name: Post JIRA Comment + id: post_jira_comment + if: success() && env.JIRA_ID != '' + env: + JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID from the commit message + JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} # Jira username from secrets + JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} # Jira password from secrets + COMMENT: ${{ env.COMMENT }} # The comment prepared in the previous step + run: | + echo -e "${JIRA_ID}" + + # Define the JIRA comment API endpoint + JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${JIRA_ID}/comment" + + # Post the comment to JIRA using basic auth with username and password + response=$(curl -s -w "%{http_code}" -X POST \ + -H "Content-Type: application/json" \ + -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ + --data "{\"body\": \"${COMMENT}\"}" \ + "${JIRA_API_URL}") + + http_code="${response:(-3)}" # Extract HTTP status code (last 3 characters) + response_body="${response:0:-3}" # The response body + + # Handle the API response + if [ "$http_code" -eq 201 ]; then + echo "Comment posted successfully to Jira issue ${JIRA_ID}" + elif [ "$http_code" -eq 404 ]; then + echo "Jira issue ${JIRA_ID} not found. No comment posted." + else + echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" + echo "Response Body: $response_body" + fi From f002458d2be4981619cda0558d0ba573acd3828f Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 24 Oct 2024 10:12:41 +1100 Subject: [PATCH 20/61] cleanup --- .github/workflows/test_notify_jira.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 94a4c06c..9893163e 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -35,7 +35,6 @@ jobs: # Check if JIRA ID is found if [ -z "$JIRA_ID" ]; then echo "No JIRA ID found in commit message: $commit_message" - exit 0 # Exit gracefully without failing the job else echo "Extracted JIRA ID: $JIRA_ID" echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV @@ -44,21 +43,16 @@ jobs: - name: Determine the workflow status id: determine_e2e_status - if: success() && env.JIRA_ID != '' - env: - JIRA_ID: ${{ env.JIRA_ID }} - STATUS: ${{ inputs.status }} + if: env.JIRA_ID != '' run: | echo "Overall workflow status: $STATUS" echo "STATUS=$STATUS" >> $GITHUB_ENV - name: Prepare JIRA Comment id: prepare_jira_comment - if: success() && env.JIRA_ID != '' + if: env.JIRA_ID != '' env: - JIRA_ID: ${{ env.JIRA_ID }} WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run - STATUS: ${{ env.STATUS }} run: | echo "Preparing JIRA comment..." @@ -75,9 +69,8 @@ jobs: - name: Post JIRA Comment id: post_jira_comment - if: success() && env.JIRA_ID != '' + if: env.JIRA_ID != '' env: - JIRA_ID: ${{ env.JIRA_ID }} # Use the extracted JIRA ID from the commit message JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} # Jira username from secrets JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} # Jira password from secrets COMMENT: ${{ env.COMMENT }} # The comment prepared in the previous step From dc05ef79264123b64aa702a6a425e04252d5a045 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 24 Oct 2024 10:25:15 +1100 Subject: [PATCH 21/61] cleanup --- .github/workflows/test_notify_jira.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 9893163e..6c1755b4 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -41,12 +41,12 @@ jobs: fi - - name: Determine the workflow status + - name: Set the workflow status id: determine_e2e_status if: env.JIRA_ID != '' run: | + echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV echo "Overall workflow status: $STATUS" - echo "STATUS=$STATUS" >> $GITHUB_ENV - name: Prepare JIRA Comment id: prepare_jira_comment From 8b58e415a5b3716fe39c403b0af6760ecf7be862 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 24 Oct 2024 10:33:51 +1100 Subject: [PATCH 22/61] cleanup --- .github/workflows/test_notify_jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 6c1755b4..7cfe19d6 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -46,7 +46,7 @@ jobs: if: env.JIRA_ID != '' run: | echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV - echo "Overall workflow status: $STATUS" + echo "Overall workflow status: ${STATUS}" - name: Prepare JIRA Comment id: prepare_jira_comment From b23e2bfd4f4eece544e8b99f0ca4e5c40fcd484a Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 24 Oct 2024 11:02:36 +1100 Subject: [PATCH 23/61] cleanup --- .github/workflows/test_notify_jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 7cfe19d6..73f286ec 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -42,7 +42,7 @@ jobs: - name: Set the workflow status - id: determine_e2e_status + id: set_e2e_status if: env.JIRA_ID != '' run: | echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV From 418720f26d135efa59cb89472b82f12ca5ce1cdd Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 24 Oct 2024 11:06:09 +1100 Subject: [PATCH 24/61] cleanup --- .github/workflows/test_notify_jira.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 73f286ec..eab38b62 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -93,8 +93,6 @@ jobs: # Handle the API response if [ "$http_code" -eq 201 ]; then echo "Comment posted successfully to Jira issue ${JIRA_ID}" - elif [ "$http_code" -eq 404 ]; then - echo "Jira issue ${JIRA_ID} not found. No comment posted." else echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" echo "Response Body: $response_body" From 4ec1728b0be4a21ac808408a4ac875ae0f33cf39 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 24 Oct 2024 11:12:12 +1100 Subject: [PATCH 25/61] cleanup --- .github/workflows/test_notify_jira.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index eab38b62..22fbbcc3 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -71,8 +71,8 @@ jobs: id: post_jira_comment if: env.JIRA_ID != '' env: - JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} # Jira username from secrets - JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} # Jira password from secrets + JIRA_USERNAME: ${{ secrets.TEST_JIRA_USERNAME }} # Jira username from secrets + JIRA_PASSWORD: ${{ secrets.TEST_JIRA_PASSWORD }} # Jira password from secrets COMMENT: ${{ env.COMMENT }} # The comment prepared in the previous step run: | echo -e "${JIRA_ID}" From e2171c6b0ccbf33597cb6f68b3af115b7d5fdccc Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 24 Oct 2024 12:31:35 +1100 Subject: [PATCH 26/61] cleanup --- .github/workflows/test_notify_jira.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 22fbbcc3..9789211e 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -96,4 +96,5 @@ jobs: else echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" echo "Response Body: $response_body" + exit 1 fi From 3add18c240c913852f7313c10da6a3753d391c08 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 24 Oct 2024 12:50:05 +1100 Subject: [PATCH 27/61] cleanup --- .github/workflows/test_notify_jira.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 9789211e..22fbbcc3 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -96,5 +96,4 @@ jobs: else echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" echo "Response Body: $response_body" - exit 1 fi From 31ca2a69dd528cfafcf64da1605f65d03a443c6a Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 09:34:57 +1100 Subject: [PATCH 28/61] split --- .github/workflows/post_jira_comment.yml | 49 +++++++++++++++++++++++++ .github/workflows/test_notify_jira.yml | 41 +++++++-------------- 2 files changed, 62 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/post_jira_comment.yml diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml new file mode 100644 index 00000000..a1d49460 --- /dev/null +++ b/.github/workflows/post_jira_comment.yml @@ -0,0 +1,49 @@ +name: post_jira_comment + +on: + workflow_call: + inputs: + jira_id: + type: string + required: true + default: "" + comment: + type: string + required: true + default: "" + + +jobs: + notify_jira: + runs-on: ubuntu-latest + steps: + - name: Post JIRA Comment + id: post_jira_comment + env: + JIRA_USERNAME: ${{ secrets.TEST_JIRA_USERNAME }} # Jira username from secrets + JIRA_PASSWORD: ${{ secrets.TEST_JIRA_PASSWORD }} # Jira password from secrets + run: | + echo "JIRA_ID=${{ inputs.jira_id }}" >> $GITHUB_ENV + echo "COMMENT=${{ inputs.comment }}" >> $GITHUB_ENV + echo -e "${JIRA_ID}" + echo -e "${COMMENT}" + # Define the JIRA comment API endpoint + JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${JIRA_ID}/comment" + + # Post the comment to JIRA using basic auth with username and password + response=$(curl -s -w "%{http_code}" -X POST \ + -H "Content-Type: application/json" \ + -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ + --data "{\"body\": \"${COMMENT}\"}" \ + "${JIRA_API_URL}") + + http_code="${response:(-3)}" # Extract HTTP status code (last 3 characters) + response_body="${response:0:-3}" # The response body + + # Handle the API response + if [ "$http_code" -eq 201 ]; then + echo "Comment posted successfully to Jira issue ${JIRA_ID}" + else + echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" + echo "Response Body: $response_body" + fi diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 22fbbcc3..b1ed976b 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -67,33 +67,18 @@ jobs: echo -e "COMMENT:\n${COMMENT}" echo "COMMENT=$COMMENT" >> $GITHUB_ENV - - name: Post JIRA Comment - id: post_jira_comment - if: env.JIRA_ID != '' - env: - JIRA_USERNAME: ${{ secrets.TEST_JIRA_USERNAME }} # Jira username from secrets - JIRA_PASSWORD: ${{ secrets.TEST_JIRA_PASSWORD }} # Jira password from secrets - COMMENT: ${{ env.COMMENT }} # The comment prepared in the previous step - run: | - echo -e "${JIRA_ID}" - - # Define the JIRA comment API endpoint - JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${JIRA_ID}/comment" + # - name: Post JIRA Comment + # if: env.JIRA_ID != '' + # uses: ./.github/workflows/post_jira_comment.yml + # with: + # JIRA_ID: ${{ env.JIRA_ID }} + # COMMENT: ${{ env.COMMENT }} - # Post the comment to JIRA using basic auth with username and password - response=$(curl -s -w "%{http_code}" -X POST \ - -H "Content-Type: application/json" \ - -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ - --data "{\"body\": \"${COMMENT}\"}" \ - "${JIRA_API_URL}") + post_jira_comment: + uses: ./.github/workflows/post_jira_comment.yml + if: env.JIRA_ID != '' + secrets: inherit + with: + jira_id: ${{ env.JIRA_ID }} + comment: ${{ env.COMMENT }} - http_code="${response:(-3)}" # Extract HTTP status code (last 3 characters) - response_body="${response:0:-3}" # The response body - - # Handle the API response - if [ "$http_code" -eq 201 ]; then - echo "Comment posted successfully to Jira issue ${JIRA_ID}" - else - echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" - echo "Response Body: $response_body" - fi From 2c77a96da3b42d3a54ac0da9aebd53a0c05a9574 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 10:00:14 +1100 Subject: [PATCH 29/61] split --- .github/workflows/test_notify_jira.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index b1ed976b..ecef10be 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -79,6 +79,6 @@ jobs: if: env.JIRA_ID != '' secrets: inherit with: - jira_id: ${{ env.JIRA_ID }} - comment: ${{ env.COMMENT }} + jira_id: ${{ needs.notify_jira.outputs.JIRA_ID }} + comment: ${{ needs.notify_jira.outputs.COMMENT }} From 818f6d688663ba23bb5edc8ff0a81309b89a1871 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 10:02:43 +1100 Subject: [PATCH 30/61] split --- .github/workflows/test_notify_jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index ecef10be..5fd7fb0f 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -76,7 +76,7 @@ jobs: post_jira_comment: uses: ./.github/workflows/post_jira_comment.yml - if: env.JIRA_ID != '' + if: needs.notify_jira.outputs.jira_id != '' secrets: inherit with: jira_id: ${{ needs.notify_jira.outputs.JIRA_ID }} From 872484e96b14ca8384092f16314a628eba4054ef Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 10:51:32 +1100 Subject: [PATCH 31/61] split --- .github/workflows/test_notify_jira.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 5fd7fb0f..095fe374 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -11,6 +11,9 @@ on: jobs: notify_jira: runs-on: ubuntu-latest + outputs: + jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} + comment: ${{ steps.prepare_jira_comment.outputs.comment }} steps: - name: Extract JIRA ID from the commit message id: extract_jira_id @@ -76,7 +79,7 @@ jobs: post_jira_comment: uses: ./.github/workflows/post_jira_comment.yml - if: needs.notify_jira.outputs.jira_id != '' + needs: [notify_jira] secrets: inherit with: jira_id: ${{ needs.notify_jira.outputs.JIRA_ID }} From 1da0638a22643ae5dd9c7548422f3652293a6708 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 11:08:36 +1100 Subject: [PATCH 32/61] split --- .github/workflows/post_jira_comment.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index a1d49460..0bb6f864 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -14,7 +14,7 @@ on: jobs: - notify_jira: + post_jira_comment: runs-on: ubuntu-latest steps: - name: Post JIRA Comment @@ -23,6 +23,8 @@ jobs: JIRA_USERNAME: ${{ secrets.TEST_JIRA_USERNAME }} # Jira username from secrets JIRA_PASSWORD: ${{ secrets.TEST_JIRA_PASSWORD }} # Jira password from secrets run: | + echo "Received JIRA ID: ${{ inputs.jira_id }}" + echo "Received COMMENT: ${{ inputs.comment }}" echo "JIRA_ID=${{ inputs.jira_id }}" >> $GITHUB_ENV echo "COMMENT=${{ inputs.comment }}" >> $GITHUB_ENV echo -e "${JIRA_ID}" From 233ace3e3502ec53a70a72511c0027aec2d6a690 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 12:11:42 +1100 Subject: [PATCH 33/61] SCFA-898 test --- .github/workflows/test_notify_jira.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 095fe374..767685d5 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -82,6 +82,6 @@ jobs: needs: [notify_jira] secrets: inherit with: - jira_id: ${{ needs.notify_jira.outputs.JIRA_ID }} - comment: ${{ needs.notify_jira.outputs.COMMENT }} + jira_id: ${{ needs.notify_jira.outputs.jira_id }} + comment: ${{ needs.notify_jira.outputs.comment }} From 051f68d16490c2febfe359464809a78408dac3ac Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 12:22:56 +1100 Subject: [PATCH 34/61] split --- .github/workflows/test_notify_jira.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 767685d5..6aa97587 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -41,6 +41,7 @@ jobs: else echo "Extracted JIRA ID: $JIRA_ID" echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV + echo "::set-output name=jira_id::$JIRA_ID" fi @@ -69,6 +70,7 @@ jobs: # Print the comment to the console for debugging echo -e "COMMENT:\n${COMMENT}" echo "COMMENT=$COMMENT" >> $GITHUB_ENV + echo "::set-output name=comment::$COMMENT" # - name: Post JIRA Comment # if: env.JIRA_ID != '' From 63a6c1dccbac7b9d2f9e7515807cb4a356b96e29 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 12:32:40 +1100 Subject: [PATCH 35/61] split --- .github/workflows/test_notify_jira.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 6aa97587..489beee3 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -41,7 +41,8 @@ jobs: else echo "Extracted JIRA ID: $JIRA_ID" echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV - echo "::set-output name=jira_id::$JIRA_ID" + echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" + fi @@ -70,7 +71,7 @@ jobs: # Print the comment to the console for debugging echo -e "COMMENT:\n${COMMENT}" echo "COMMENT=$COMMENT" >> $GITHUB_ENV - echo "::set-output name=comment::$COMMENT" + echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" # - name: Post JIRA Comment # if: env.JIRA_ID != '' From 34c5bd313886f175d5734eff7e1c69204977acb2 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 12:40:47 +1100 Subject: [PATCH 36/61] split --- .github/workflows/post_jira_comment.yml | 10 +++++++++- .github/workflows/test_notify_jira.yml | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index 0bb6f864..ebd28a01 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -11,6 +11,14 @@ on: type: string required: true default: "" + jira_username: + type: string + required: true + default: "" + jira_password: + type: string + required: true + default: "" jobs: @@ -35,7 +43,7 @@ jobs: # Post the comment to JIRA using basic auth with username and password response=$(curl -s -w "%{http_code}" -X POST \ -H "Content-Type: application/json" \ - -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ + -u "${{ inputs.jira_username }}:${{ inputs.jira_password }}" \ --data "{\"body\": \"${COMMENT}\"}" \ "${JIRA_API_URL}") diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 489beee3..1c17ed0f 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -87,4 +87,5 @@ jobs: with: jira_id: ${{ needs.notify_jira.outputs.jira_id }} comment: ${{ needs.notify_jira.outputs.comment }} - + jira_username: ${{ secrets.TEST_JIRA_USERNAME }} + jira_password: ${{ secrets.TEST_JIRA_PASSWORD }} From cc7d1b49137247e8c5ce5781130d0d99e599eb50 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 12:47:46 +1100 Subject: [PATCH 37/61] split --- .github/workflows/post_jira_comment.yml | 7 +++---- .github/workflows/test_notify_jira.yml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index ebd28a01..f6c8ebf4 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -20,7 +20,6 @@ on: required: true default: "" - jobs: post_jira_comment: runs-on: ubuntu-latest @@ -28,8 +27,8 @@ jobs: - name: Post JIRA Comment id: post_jira_comment env: - JIRA_USERNAME: ${{ secrets.TEST_JIRA_USERNAME }} # Jira username from secrets - JIRA_PASSWORD: ${{ secrets.TEST_JIRA_PASSWORD }} # Jira password from secrets + JIRA_USERNAME: ${{ inputs.jira_password }} # Jira username from secrets + JIRA_PASSWORD: ${{ inputs.jira_username }} # Jira password from secrets run: | echo "Received JIRA ID: ${{ inputs.jira_id }}" echo "Received COMMENT: ${{ inputs.comment }}" @@ -43,7 +42,7 @@ jobs: # Post the comment to JIRA using basic auth with username and password response=$(curl -s -w "%{http_code}" -X POST \ -H "Content-Type: application/json" \ - -u "${{ inputs.jira_username }}:${{ inputs.jira_password }}" \ + -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ --data "{\"body\": \"${COMMENT}\"}" \ "${JIRA_API_URL}") diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 1c17ed0f..89a3c9b5 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -88,4 +88,4 @@ jobs: jira_id: ${{ needs.notify_jira.outputs.jira_id }} comment: ${{ needs.notify_jira.outputs.comment }} jira_username: ${{ secrets.TEST_JIRA_USERNAME }} - jira_password: ${{ secrets.TEST_JIRA_PASSWORD }} + jira_password: ${{ secrets.TEST_JIRA_PASSWORD }} \ No newline at end of file From 464137d3bd127ef66c82ceadbf170a9870da5b2b Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 12:48:02 +1100 Subject: [PATCH 38/61] split --- .github/workflows/post_jira_comment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index f6c8ebf4..0a45e3b3 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -27,8 +27,8 @@ jobs: - name: Post JIRA Comment id: post_jira_comment env: - JIRA_USERNAME: ${{ inputs.jira_password }} # Jira username from secrets - JIRA_PASSWORD: ${{ inputs.jira_username }} # Jira password from secrets + JIRA_USERNAME: ${{ inputs.jira_password }} + JIRA_PASSWORD: ${{ inputs.jira_username }} run: | echo "Received JIRA ID: ${{ inputs.jira_id }}" echo "Received COMMENT: ${{ inputs.comment }}" From a225a5b46bfd4680a9f7d96064de7333de03a051 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 12:59:37 +1100 Subject: [PATCH 39/61] test --- .github/workflows/post_jira_comment.yml | 12 ++---------- .github/workflows/test_notify_jira.yml | 3 +-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index 0a45e3b3..21bdd66f 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -11,14 +11,6 @@ on: type: string required: true default: "" - jira_username: - type: string - required: true - default: "" - jira_password: - type: string - required: true - default: "" jobs: post_jira_comment: @@ -27,8 +19,8 @@ jobs: - name: Post JIRA Comment id: post_jira_comment env: - JIRA_USERNAME: ${{ inputs.jira_password }} - JIRA_PASSWORD: ${{ inputs.jira_username }} + JIRA_USERNAME: ${{ secrets.TEST_JIRA_USERNAME }} + JIRA_PASSWORD: ${{ secrets.TEST_JIRA_PASSWORD }} run: | echo "Received JIRA ID: ${{ inputs.jira_id }}" echo "Received COMMENT: ${{ inputs.comment }}" diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml index 89a3c9b5..2ad397c1 100644 --- a/.github/workflows/test_notify_jira.yml +++ b/.github/workflows/test_notify_jira.yml @@ -87,5 +87,4 @@ jobs: with: jira_id: ${{ needs.notify_jira.outputs.jira_id }} comment: ${{ needs.notify_jira.outputs.comment }} - jira_username: ${{ secrets.TEST_JIRA_USERNAME }} - jira_password: ${{ secrets.TEST_JIRA_PASSWORD }} \ No newline at end of file + From 19438458ddbd54b2c1b735b9bd0e5f996e290edd Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 13:08:48 +1100 Subject: [PATCH 40/61] inputs --- .github/workflows/post_jira_comment.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index 21bdd66f..20d5aaa1 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -29,13 +29,13 @@ jobs: echo -e "${JIRA_ID}" echo -e "${COMMENT}" # Define the JIRA comment API endpoint - JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${JIRA_ID}/comment" + JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${{ inputs.jira_id }}/comment" # Post the comment to JIRA using basic auth with username and password response=$(curl -s -w "%{http_code}" -X POST \ -H "Content-Type: application/json" \ -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ - --data "{\"body\": \"${COMMENT}\"}" \ + --data "{\"body\": \"${{ inputs.comment }}\"}" \ "${JIRA_API_URL}") http_code="${response:(-3)}" # Extract HTTP status code (last 3 characters) @@ -43,8 +43,8 @@ jobs: # Handle the API response if [ "$http_code" -eq 201 ]; then - echo "Comment posted successfully to Jira issue ${JIRA_ID}" + echo "Comment posted successfully to Jira issue ${{ inputs.jira_id }}" else - echo "Failed to post comment to Jira issue ${JIRA_ID}. HTTP Code: $http_code" + echo "Failed to post comment to Jira issue ${{ inputs.jira_id }}. HTTP Code: $http_code" echo "Response Body: $response_body" fi From c7b0e39637d24d58eb6a9005350a9b7051581b0e Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 15:50:09 +1100 Subject: [PATCH 41/61] inputs --- .github/workflows/post_jira_comment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index 20d5aaa1..c01c616a 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -19,8 +19,8 @@ jobs: - name: Post JIRA Comment id: post_jira_comment env: - JIRA_USERNAME: ${{ secrets.TEST_JIRA_USERNAME }} - JIRA_PASSWORD: ${{ secrets.TEST_JIRA_PASSWORD }} + JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} + JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} run: | echo "Received JIRA ID: ${{ inputs.jira_id }}" echo "Received COMMENT: ${{ inputs.comment }}" From d6e2295f48b1b14ff9d572aa47f8cdfd5a7c6a5e Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 16:06:20 +1100 Subject: [PATCH 42/61] moved post jira notification out --- .github/workflows/test_notify_jira.yml | 90 -------------------------- 1 file changed, 90 deletions(-) delete mode 100644 .github/workflows/test_notify_jira.yml diff --git a/.github/workflows/test_notify_jira.yml b/.github/workflows/test_notify_jira.yml deleted file mode 100644 index 2ad397c1..00000000 --- a/.github/workflows/test_notify_jira.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: test_notify_jira - -on: - workflow_call: - inputs: - status: - type: string - required: true - default: "" - -jobs: - notify_jira: - runs-on: ubuntu-latest - outputs: - jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} - comment: ${{ steps.prepare_jira_comment.outputs.comment }} - steps: - - name: Extract JIRA ID from the commit message - id: extract_jira_id - run: | - # Fetch commit message from the GitHub API - commit_info=$(curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) - - # Check if curl was successful - if [ $? -ne 0 ]; then - echo "Failed to fetch commit message." - exit 0 # Exit gracefully on curl failure - fi - - commit_message=$(echo "$commit_info" | jq -r '.commit.message') - - # Extract JIRA ID - JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code - - # Check if JIRA ID is found - if [ -z "$JIRA_ID" ]; then - echo "No JIRA ID found in commit message: $commit_message" - else - echo "Extracted JIRA ID: $JIRA_ID" - echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV - echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" - - fi - - - - name: Set the workflow status - id: set_e2e_status - if: env.JIRA_ID != '' - run: | - echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV - echo "Overall workflow status: ${STATUS}" - - - name: Prepare JIRA Comment - id: prepare_jira_comment - if: env.JIRA_ID != '' - env: - WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run - run: | - echo "Preparing JIRA comment..." - - # Determine the branch name from the Git reference - GIT_BRANCH=${GITHUB_REF##*/} - - # Construct the comment template - COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" - COMMENT+="Workflow URL: $WORKFLOW_LINK" - - # Print the comment to the console for debugging - echo -e "COMMENT:\n${COMMENT}" - echo "COMMENT=$COMMENT" >> $GITHUB_ENV - echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" - - # - name: Post JIRA Comment - # if: env.JIRA_ID != '' - # uses: ./.github/workflows/post_jira_comment.yml - # with: - # JIRA_ID: ${{ env.JIRA_ID }} - # COMMENT: ${{ env.COMMENT }} - - post_jira_comment: - uses: ./.github/workflows/post_jira_comment.yml - needs: [notify_jira] - secrets: inherit - with: - jira_id: ${{ needs.notify_jira.outputs.jira_id }} - comment: ${{ needs.notify_jira.outputs.comment }} - From 72d4601d086aed60140ace8e62182a7689590359 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 16:17:12 +1100 Subject: [PATCH 43/61] moved post jira notification out --- .../test_prepare_e2e_jira_notification.yml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/test_prepare_e2e_jira_notification.yml diff --git a/.github/workflows/test_prepare_e2e_jira_notification.yml b/.github/workflows/test_prepare_e2e_jira_notification.yml new file mode 100644 index 00000000..b50a5cd6 --- /dev/null +++ b/.github/workflows/test_prepare_e2e_jira_notification.yml @@ -0,0 +1,83 @@ +name: prepare_e2e_jira_notification + +on: + workflow_call: + inputs: + status: + type: string + required: true + default: "" + +jobs: + prepare_e2e_jira_notification: + runs-on: ubuntu-latest + outputs: + jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} + comment: ${{ steps.prepare_jira_comment.outputs.comment }} + steps: + - name: Extract JIRA ID from the commit message + id: extract_jira_id + run: | + # Fetch commit message from the GitHub API + commit_info=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) + + # Check if curl was successful + if [ $? -ne 0 ]; then + echo "Failed to fetch commit message." + exit 0 # Exit gracefully on curl failure + fi + + commit_message=$(echo "$commit_info" | jq -r '.commit.message') + + # Extract JIRA ID + JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code + + # Check if JIRA ID is found + if [ -z "$JIRA_ID" ]; then + echo "No JIRA ID found in commit message: $commit_message" + else + echo "Extracted JIRA ID: $JIRA_ID" + echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV + echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" + + fi + + - name: Set the workflow status + id: set_e2e_status + if: env.JIRA_ID != '' + run: | + echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV + echo "Overall workflow status: ${STATUS}" + + - name: Prepare JIRA Comment + id: prepare_jira_comment + if: env.JIRA_ID != '' + env: + WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run + run: | + echo "Preparing JIRA comment..." + + # Determine the branch name from the Git reference + GIT_BRANCH=${GITHUB_REF##*/} + + # Construct the comment template + COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" + COMMENT+="Workflow URL: $WORKFLOW_LINK" + + # Print the comment to the console for debugging + echo -e "COMMENT:\n${COMMENT}" + echo "COMMENT=$COMMENT" >> $GITHUB_ENV + echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" + + post_jira_comment: + uses: ./.github/workflows/post_jira_comment.yml + needs: [notify_jira] + secrets: inherit + with: + jira_id: ${{ needs.notify_jira.outputs.jira_id }} + comment: ${{ needs.notify_jira.outputs.comment }} + JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} + JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} From d26259f1d6e4d62006d9d2341d377cdd2a9f20df Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 16:30:12 +1100 Subject: [PATCH 44/61] moved post jira notification out --- .github/workflows/test_prepare_e2e_jira_notification.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test_prepare_e2e_jira_notification.yml b/.github/workflows/test_prepare_e2e_jira_notification.yml index b50a5cd6..355325f6 100644 --- a/.github/workflows/test_prepare_e2e_jira_notification.yml +++ b/.github/workflows/test_prepare_e2e_jira_notification.yml @@ -79,5 +79,4 @@ jobs: with: jira_id: ${{ needs.notify_jira.outputs.jira_id }} comment: ${{ needs.notify_jira.outputs.comment }} - JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} - JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} + From 6184f49d2435bb32c0c8cb5501de20e66e5e5739 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 17:07:44 +1100 Subject: [PATCH 45/61] moved post jira notification out --- .github/workflows/test_prepare_e2e_jira_notification.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_prepare_e2e_jira_notification.yml b/.github/workflows/test_prepare_e2e_jira_notification.yml index 355325f6..0239bd78 100644 --- a/.github/workflows/test_prepare_e2e_jira_notification.yml +++ b/.github/workflows/test_prepare_e2e_jira_notification.yml @@ -1,4 +1,4 @@ -name: prepare_e2e_jira_notification +name: test_prepare_e2e_jira_notification on: workflow_call: @@ -9,7 +9,7 @@ on: default: "" jobs: - prepare_e2e_jira_notification: + test_prepare_e2e_jira_notification: runs-on: ubuntu-latest outputs: jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} From 9c1dd86b626b2ebb80bb9bc4a093435555debfa4 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 17:12:36 +1100 Subject: [PATCH 46/61] moved post jira notification out --- .github/workflows/test_prepare_e2e_jira_notification.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_prepare_e2e_jira_notification.yml b/.github/workflows/test_prepare_e2e_jira_notification.yml index 0239bd78..a983ccd4 100644 --- a/.github/workflows/test_prepare_e2e_jira_notification.yml +++ b/.github/workflows/test_prepare_e2e_jira_notification.yml @@ -74,7 +74,7 @@ jobs: post_jira_comment: uses: ./.github/workflows/post_jira_comment.yml - needs: [notify_jira] + needs: [test_prepare_e2e_jira_notification] secrets: inherit with: jira_id: ${{ needs.notify_jira.outputs.jira_id }} From ba3abbc74ca33defbf56b6e63ad90ae896b8503c Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 17:22:30 +1100 Subject: [PATCH 47/61] SCFA-898 test --- .github/workflows/test_prepare_e2e_jira_notification.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_prepare_e2e_jira_notification.yml b/.github/workflows/test_prepare_e2e_jira_notification.yml index a983ccd4..386aaad7 100644 --- a/.github/workflows/test_prepare_e2e_jira_notification.yml +++ b/.github/workflows/test_prepare_e2e_jira_notification.yml @@ -77,6 +77,6 @@ jobs: needs: [test_prepare_e2e_jira_notification] secrets: inherit with: - jira_id: ${{ needs.notify_jira.outputs.jira_id }} - comment: ${{ needs.notify_jira.outputs.comment }} + jira_id: ${{ needs.test_prepare_e2e_jira_notification.outputs.jira_id }} + comment: ${{ needs.test_prepare_e2e_jira_notification.outputs.comment }} From 3723cc6126c6e05a072b9c7ab60b394fe98e5529 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 17:25:59 +1100 Subject: [PATCH 48/61] SCFA-898 test --- .../test_prepare_e2e_jira_notification.yml | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100644 .github/workflows/test_prepare_e2e_jira_notification.yml diff --git a/.github/workflows/test_prepare_e2e_jira_notification.yml b/.github/workflows/test_prepare_e2e_jira_notification.yml deleted file mode 100644 index 386aaad7..00000000 --- a/.github/workflows/test_prepare_e2e_jira_notification.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: test_prepare_e2e_jira_notification - -on: - workflow_call: - inputs: - status: - type: string - required: true - default: "" - -jobs: - test_prepare_e2e_jira_notification: - runs-on: ubuntu-latest - outputs: - jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} - comment: ${{ steps.prepare_jira_comment.outputs.comment }} - steps: - - name: Extract JIRA ID from the commit message - id: extract_jira_id - run: | - # Fetch commit message from the GitHub API - commit_info=$(curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) - - # Check if curl was successful - if [ $? -ne 0 ]; then - echo "Failed to fetch commit message." - exit 0 # Exit gracefully on curl failure - fi - - commit_message=$(echo "$commit_info" | jq -r '.commit.message') - - # Extract JIRA ID - JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code - - # Check if JIRA ID is found - if [ -z "$JIRA_ID" ]; then - echo "No JIRA ID found in commit message: $commit_message" - else - echo "Extracted JIRA ID: $JIRA_ID" - echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV - echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" - - fi - - - name: Set the workflow status - id: set_e2e_status - if: env.JIRA_ID != '' - run: | - echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV - echo "Overall workflow status: ${STATUS}" - - - name: Prepare JIRA Comment - id: prepare_jira_comment - if: env.JIRA_ID != '' - env: - WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run - run: | - echo "Preparing JIRA comment..." - - # Determine the branch name from the Git reference - GIT_BRANCH=${GITHUB_REF##*/} - - # Construct the comment template - COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" - COMMENT+="Workflow URL: $WORKFLOW_LINK" - - # Print the comment to the console for debugging - echo -e "COMMENT:\n${COMMENT}" - echo "COMMENT=$COMMENT" >> $GITHUB_ENV - echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" - - post_jira_comment: - uses: ./.github/workflows/post_jira_comment.yml - needs: [test_prepare_e2e_jira_notification] - secrets: inherit - with: - jira_id: ${{ needs.test_prepare_e2e_jira_notification.outputs.jira_id }} - comment: ${{ needs.test_prepare_e2e_jira_notification.outputs.comment }} - From 8e47617dd2ef4433909a97e2b83ff2dc7bc2b28e Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 17:30:45 +1100 Subject: [PATCH 49/61] SCFA-898 test --- .github/workflows/test_prepare_jira.yml | 82 +++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/test_prepare_jira.yml diff --git a/.github/workflows/test_prepare_jira.yml b/.github/workflows/test_prepare_jira.yml new file mode 100644 index 00000000..3307251b --- /dev/null +++ b/.github/workflows/test_prepare_jira.yml @@ -0,0 +1,82 @@ +name: test_prepare_jira + +on: + workflow_call: + inputs: + status: + type: string + required: true + default: "" + +jobs: + test_prepare_jira: + runs-on: ubuntu-latest + outputs: + jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} + comment: ${{ steps.prepare_jira_comment.outputs.comment }} + steps: + - name: Extract JIRA ID from the commit message + id: extract_jira_id + run: | + # Fetch commit message from the GitHub API + commit_info=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) + + # Check if curl was successful + if [ $? -ne 0 ]; then + echo "Failed to fetch commit message." + exit 0 # Exit gracefully on curl failure + fi + + commit_message=$(echo "$commit_info" | jq -r '.commit.message') + + # Extract JIRA ID + JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code + + # Check if JIRA ID is found + if [ -z "$JIRA_ID" ]; then + echo "No JIRA ID found in commit message: $commit_message" + else + echo "Extracted JIRA ID: $JIRA_ID" + echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV + echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" + + fi + + - name: Set the workflow status + id: set_e2e_status + if: env.JIRA_ID != '' + run: | + echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV + echo "Overall workflow status: ${STATUS}" + + - name: Prepare JIRA Comment + id: prepare_jira_comment + if: env.JIRA_ID != '' + env: + WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run + run: | + echo "Preparing JIRA comment..." + + # Determine the branch name from the Git reference + GIT_BRANCH=${GITHUB_REF##*/} + + # Construct the comment template + COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" + COMMENT+="Workflow URL: $WORKFLOW_LINK" + + # Print the comment to the console for debugging + echo -e "COMMENT:\n${COMMENT}" + echo "COMMENT=$COMMENT" >> $GITHUB_ENV + echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" + + post_jira_comment: + uses: ./.github/workflows/post_jira_comment.yml + needs: [test_prepare_jira] + secrets: inherit + with: + jira_id: ${{ needs.test_prepare_jira.outputs.jira_id }} + comment: ${{ needs.test_prepare_jira.outputs.comment }} + From c873beab5a65ee63284faa157198eb746e40621d Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 31 Oct 2024 18:48:29 +1100 Subject: [PATCH 50/61] SCFA-898 test --- .github/workflows/post_jira_comment.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index c01c616a..acf1d502 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -26,8 +26,7 @@ jobs: echo "Received COMMENT: ${{ inputs.comment }}" echo "JIRA_ID=${{ inputs.jira_id }}" >> $GITHUB_ENV echo "COMMENT=${{ inputs.comment }}" >> $GITHUB_ENV - echo -e "${JIRA_ID}" - echo -e "${COMMENT}" + # Define the JIRA comment API endpoint JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${{ inputs.jira_id }}/comment" From 53a7d18d2ebc9c2b40d20385c65919490d8123ac Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 6 Nov 2024 10:09:20 +1100 Subject: [PATCH 51/61] rename --- .github/workflows/test_prepare_jira.yml | 82 ------------------------- 1 file changed, 82 deletions(-) delete mode 100644 .github/workflows/test_prepare_jira.yml diff --git a/.github/workflows/test_prepare_jira.yml b/.github/workflows/test_prepare_jira.yml deleted file mode 100644 index 3307251b..00000000 --- a/.github/workflows/test_prepare_jira.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: test_prepare_jira - -on: - workflow_call: - inputs: - status: - type: string - required: true - default: "" - -jobs: - test_prepare_jira: - runs-on: ubuntu-latest - outputs: - jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} - comment: ${{ steps.prepare_jira_comment.outputs.comment }} - steps: - - name: Extract JIRA ID from the commit message - id: extract_jira_id - run: | - # Fetch commit message from the GitHub API - commit_info=$(curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) - - # Check if curl was successful - if [ $? -ne 0 ]; then - echo "Failed to fetch commit message." - exit 0 # Exit gracefully on curl failure - fi - - commit_message=$(echo "$commit_info" | jq -r '.commit.message') - - # Extract JIRA ID - JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code - - # Check if JIRA ID is found - if [ -z "$JIRA_ID" ]; then - echo "No JIRA ID found in commit message: $commit_message" - else - echo "Extracted JIRA ID: $JIRA_ID" - echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV - echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" - - fi - - - name: Set the workflow status - id: set_e2e_status - if: env.JIRA_ID != '' - run: | - echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV - echo "Overall workflow status: ${STATUS}" - - - name: Prepare JIRA Comment - id: prepare_jira_comment - if: env.JIRA_ID != '' - env: - WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run - run: | - echo "Preparing JIRA comment..." - - # Determine the branch name from the Git reference - GIT_BRANCH=${GITHUB_REF##*/} - - # Construct the comment template - COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" - COMMENT+="Workflow URL: $WORKFLOW_LINK" - - # Print the comment to the console for debugging - echo -e "COMMENT:\n${COMMENT}" - echo "COMMENT=$COMMENT" >> $GITHUB_ENV - echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" - - post_jira_comment: - uses: ./.github/workflows/post_jira_comment.yml - needs: [test_prepare_jira] - secrets: inherit - with: - jira_id: ${{ needs.test_prepare_jira.outputs.jira_id }} - comment: ${{ needs.test_prepare_jira.outputs.comment }} - From e31bf4234a12960149cc1cf52cc1ef09121f2975 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 6 Nov 2024 10:09:26 +1100 Subject: [PATCH 52/61] rename --- .github/workflows/test_post_jira.yml | 82 ++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/test_post_jira.yml diff --git a/.github/workflows/test_post_jira.yml b/.github/workflows/test_post_jira.yml new file mode 100644 index 00000000..a67f79e6 --- /dev/null +++ b/.github/workflows/test_post_jira.yml @@ -0,0 +1,82 @@ +name: test_post_jira + +on: + workflow_call: + inputs: + status: + type: string + required: true + default: "" + +jobs: + test_post_jira: + runs-on: ubuntu-latest + outputs: + jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} + comment: ${{ steps.prepare_jira_comment.outputs.comment }} + steps: + - name: Extract JIRA ID from the commit message + id: extract_jira_id + run: | + # Fetch commit message from the GitHub API + commit_info=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) + + # Check if curl was successful + if [ $? -ne 0 ]; then + echo "Failed to fetch commit message." + exit 0 # Exit gracefully on curl failure + fi + + commit_message=$(echo "$commit_info" | jq -r '.commit.message') + + # Extract JIRA ID + JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code + + # Check if JIRA ID is found + if [ -z "$JIRA_ID" ]; then + echo "No JIRA ID found in commit message: $commit_message" + else + echo "Extracted JIRA ID: $JIRA_ID" + echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV + echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" + + fi + + - name: Set the workflow status + id: set_e2e_status + if: env.JIRA_ID != '' + run: | + echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV + echo "Overall workflow status: ${STATUS}" + + - name: Prepare JIRA Comment + id: prepare_jira_comment + if: env.JIRA_ID != '' + env: + WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run + run: | + echo "Preparing JIRA comment..." + + # Determine the branch name from the Git reference + GIT_BRANCH=${GITHUB_REF##*/} + + # Construct the comment template + COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" + COMMENT+="Workflow URL: $WORKFLOW_LINK" + + # Print the comment to the console for debugging + echo -e "COMMENT:\n${COMMENT}" + echo "COMMENT=$COMMENT" >> $GITHUB_ENV + echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" + + post_jira_comment: + uses: ./.github/workflows/post_jira_comment.yml + needs: [test_post_jira] + secrets: inherit + with: + jira_id: ${{ needs.test_post_jira.outputs.jira_id }} + comment: ${{ needs.test_post_jira.outputs.comment }} + From 33d8c989f4759b278590f7192f464cf60046f9dd Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 6 Nov 2024 10:48:13 +1100 Subject: [PATCH 53/61] remove status and use input --- .github/workflows/test_post_jira.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_post_jira.yml b/.github/workflows/test_post_jira.yml index a67f79e6..2f35cf50 100644 --- a/.github/workflows/test_post_jira.yml +++ b/.github/workflows/test_post_jira.yml @@ -44,13 +44,6 @@ jobs: echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" fi - - - name: Set the workflow status - id: set_e2e_status - if: env.JIRA_ID != '' - run: | - echo 'STATUS=${{ inputs.status }}' >> $GITHUB_ENV - echo "Overall workflow status: ${STATUS}" - name: Prepare JIRA Comment id: prepare_jira_comment @@ -64,13 +57,14 @@ jobs: GIT_BRANCH=${GITHUB_REF##*/} # Construct the comment template - COMMENT="E2E Test - ${STATUS} on branch ${GIT_BRANCH}\n" + COMMENT="E2E Test - ${{ inputs.status }} on branch ${GIT_BRANCH}\n" COMMENT+="Workflow URL: $WORKFLOW_LINK" # Print the comment to the console for debugging echo -e "COMMENT:\n${COMMENT}" echo "COMMENT=$COMMENT" >> $GITHUB_ENV echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" + echo "${{ inputs.status }}" post_jira_comment: uses: ./.github/workflows/post_jira_comment.yml From ace05511a6ced036860595190df2c6f3778f9f02 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 6 Nov 2024 11:08:50 +1100 Subject: [PATCH 54/61] remove comment env var --- .github/workflows/test_post_jira.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test_post_jira.yml b/.github/workflows/test_post_jira.yml index 2f35cf50..de69a19c 100644 --- a/.github/workflows/test_post_jira.yml +++ b/.github/workflows/test_post_jira.yml @@ -61,9 +61,6 @@ jobs: COMMENT+="Workflow URL: $WORKFLOW_LINK" # Print the comment to the console for debugging - echo -e "COMMENT:\n${COMMENT}" - echo "COMMENT=$COMMENT" >> $GITHUB_ENV - echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" echo "${{ inputs.status }}" post_jira_comment: From 868756f12ce8014041e9574bbb47d822096827ac Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 6 Nov 2024 11:35:37 +1100 Subject: [PATCH 55/61] prep name job --- .github/workflows/test_post_jira.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_post_jira.yml b/.github/workflows/test_post_jira.yml index de69a19c..36f8f6a6 100644 --- a/.github/workflows/test_post_jira.yml +++ b/.github/workflows/test_post_jira.yml @@ -9,7 +9,7 @@ on: default: "" jobs: - test_post_jira: + test_prepare_jira: runs-on: ubuntu-latest outputs: jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} @@ -61,13 +61,14 @@ jobs: COMMENT+="Workflow URL: $WORKFLOW_LINK" # Print the comment to the console for debugging + echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" echo "${{ inputs.status }}" post_jira_comment: uses: ./.github/workflows/post_jira_comment.yml - needs: [test_post_jira] + needs: [test_prepare_jira] secrets: inherit with: - jira_id: ${{ needs.test_post_jira.outputs.jira_id }} - comment: ${{ needs.test_post_jira.outputs.comment }} + jira_id: ${{ needs.test_prepare_jira.outputs.jira_id }} + comment: ${{ needs.test_prepare_jira.outputs.comment }} From 233e022a3a577981eebf2b7ab3891445bad2e26f Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 6 Nov 2024 11:36:58 +1100 Subject: [PATCH 56/61] prep name job --- .github/workflows/test_post_jira.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test_post_jira.yml b/.github/workflows/test_post_jira.yml index 36f8f6a6..11028245 100644 --- a/.github/workflows/test_post_jira.yml +++ b/.github/workflows/test_post_jira.yml @@ -42,7 +42,6 @@ jobs: echo "Extracted JIRA ID: $JIRA_ID" echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" - fi - name: Prepare JIRA Comment @@ -71,4 +70,3 @@ jobs: with: jira_id: ${{ needs.test_prepare_jira.outputs.jira_id }} comment: ${{ needs.test_prepare_jira.outputs.comment }} - From c89c7e10ea6cbd924b79dac75c190650eb6e77b9 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Wed, 6 Nov 2024 11:51:03 +1100 Subject: [PATCH 57/61] comment --- .github/workflows/test_post_jira.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_post_jira.yml b/.github/workflows/test_post_jira.yml index 11028245..f30ded4b 100644 --- a/.github/workflows/test_post_jira.yml +++ b/.github/workflows/test_post_jira.yml @@ -61,6 +61,7 @@ jobs: # Print the comment to the console for debugging echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" + echo "$COMMENT" echo "${{ inputs.status }}" post_jira_comment: From ef660904568be086f2b69876c589dfa057864193 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 7 Nov 2024 08:30:19 +1100 Subject: [PATCH 58/61] review comments --- .github/workflows/post_jira_comment.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index acf1d502..a8cedddc 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -19,14 +19,12 @@ jobs: - name: Post JIRA Comment id: post_jira_comment env: - JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} + JIRA_USERNAME: ${{ secrets.JIRA_USERNAMEaa }} JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} run: | echo "Received JIRA ID: ${{ inputs.jira_id }}" echo "Received COMMENT: ${{ inputs.comment }}" - echo "JIRA_ID=${{ inputs.jira_id }}" >> $GITHUB_ENV - echo "COMMENT=${{ inputs.comment }}" >> $GITHUB_ENV - + # Define the JIRA comment API endpoint JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${{ inputs.jira_id }}/comment" From 73ef98fe00a2762422a94dcf0bfb7f66d6b1abd1 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 7 Nov 2024 08:41:29 +1100 Subject: [PATCH 59/61] review comments step sum --- .github/workflows/post_jira_comment.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index a8cedddc..69780591 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -44,4 +44,10 @@ jobs: else echo "Failed to post comment to Jira issue ${{ inputs.jira_id }}. HTTP Code: $http_code" echo "Response Body: $response_body" + + echo '### ⚠️ Failed to post comment to Jira' >> $GITHUB_STEP_SUMMARY + echo "#### Issue ID: ${{ inputs.jira_id }}" >> $GITHUB_STEP_SUMMARY + echo "#### HTTP Code: $http_code" >> $GITHUB_STEP_SUMMARY + echo "#### Response Body: $response_body" >> $GITHUB_STEP_SUMMARY + fi From 555f2b5f910db5169beb278ed070d9de82085fcf Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 7 Nov 2024 08:51:33 +1100 Subject: [PATCH 60/61] review comments step sum --- .github/workflows/post_jira_comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index 69780591..3cdfbf81 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -19,7 +19,7 @@ jobs: - name: Post JIRA Comment id: post_jira_comment env: - JIRA_USERNAME: ${{ secrets.JIRA_USERNAMEaa }} + JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} run: | echo "Received JIRA ID: ${{ inputs.jira_id }}" From fb0aa06f55a36d4e5958192311411b5b23a89a50 Mon Sep 17 00:00:00 2001 From: Keith Lau Date: Thu, 7 Nov 2024 09:00:20 +1100 Subject: [PATCH 61/61] review comments step sum --- .github/workflows/post_jira_comment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/post_jira_comment.yml b/.github/workflows/post_jira_comment.yml index 3cdfbf81..65056a73 100644 --- a/.github/workflows/post_jira_comment.yml +++ b/.github/workflows/post_jira_comment.yml @@ -41,6 +41,7 @@ jobs: # Handle the API response if [ "$http_code" -eq 201 ]; then echo "Comment posted successfully to Jira issue ${{ inputs.jira_id }}" + echo "Response Body: $response_body" else echo "Failed to post comment to Jira issue ${{ inputs.jira_id }}. HTTP Code: $http_code" echo "Response Body: $response_body"