@@ -80,52 +80,49 @@ runs:
8080 GITHUB_REPOSITORY : ${{ github.repository }}
8181 GITHUB_WORKFLOW : ${{ github.workflow }}
8282 GITHUB_RUN_ID : ${{ github.run_id }}
83+ SLACK_THREAD_YAML : |
84+ ${{ steps.retrieve-slack-thread-id.outcome == 'success' && format('thread_ts: "{0}"', env.SLACK_THREAD_ID) || '' }}
85+ CHANNEL_ID : ${{ inputs.channel-id }}
8386 shell : bash
8487 run : |
85- WORKFLOW_RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}"
86- echo "WORKFLOW_RUN_URL=$WORKFLOW_RUN_URL" | tee -a "$GITHUB_ENV"
88+ export WORKFLOW_RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}"
8789
8890 if [ "$NOTIFICATION_TYPE" == "container-image-build" ]; then
8991 # TODO (@Techassi): Also add success template
9092 if [ "$PUBLISH_MANIFESTS_RESULT" = "failure" ] || [ "$BUILD_RESULT" = "failure" ]; then
91- MESSAGE_VERB=failed
92- echo "MESSAGE_VERB=$MESSAGE_VERB" | tee -a "$GITHUB_ENV"
93-
94- echo "MESSAGE_COLOR=aa0000" | tee -a "$GITHUB_ENV"
93+ export MESSAGE_VERB=failed
94+ export MESSAGE_COLOR=aa0000
9595 else
96- MESSAGE_VERB=succeeded
97- echo "MESSAGE_VERB=$MESSAGE_VERB" | tee -a "$GITHUB_ENV"
98-
99- echo "MESSAGE_COLOR=10c400" | tee -a "$GITHUB_ENV"
96+ export MESSAGE_VERB=succeeded
97+ export MESSAGE_COLOR=10c400
10098 fi
10199
102- echo "MESSAGE_TEXT=*$GITHUB_WORKFLOW* $MESSAGE_VERB (attempt $GITHUB_RUN_ATTEMPT)" | tee -a "$GITHUB_ENV"
103- echo -e "MESSAGE_TEMPLATE<<EOF\n$(cat ${GITHUB_ACTION_PATH}/templates/container-image-build/failure.tpl)\nEOF" | tee -a "$GITHUB_ENV"
100+ export MESSAGE_TEXT="*$GITHUB_WORKFLOW* $MESSAGE_VERB (attempt $GITHUB_RUN_ATTEMPT)"
101+ PAYLOAD=$(envsubst < "${GITHUB_ACTION_PATH}/templates/container-image-build/failure.tpl")
102+ echo -e "PAYLOAD<<EOF\n$PAYLOAD\nEOF" | tee -a "$GITHUB_ENV"
104103 elif [ "$NOTIFICATION_TYPE" == "integration-test" ]; then
105- echo " HEALTH_SLACK_EMOJI=$(echo "$TEST_HEALTH" | cut -d ',' -f 1)" | tee -a "$GITHUB_ENV"
106- echo " HEALTH_RATE=$(echo "$TEST_HEALTH" | cut -d ',' -f 3)" | tee -a "$GITHUB_ENV"
104+ export HEALTH_SLACK_EMOJI=$(echo "$TEST_HEALTH" | cut -d ',' -f 1)
105+ export HEALTH_RATE=$(echo "$TEST_HEALTH" | cut -d ',' -f 3)
107106
108107 if [ "$TEST_RESULT" == "failure" ]; then
109- echo "MESSAGE_TEXT=The integration test for *`$GITHUB_REPOSITORY`* failed." | tee -a "$GITHUB_ENV"
110- echo -e "MESSAGE_TEMPLATE<<EOF\n$(cat ${GITHUB_ACTION_PATH}/templates/integration-test/failure.tpl)\nEOF" | tee -a "$GITHUB_ENV"
108+ export MESSAGE_TEXT="The integration test for *`$GITHUB_REPOSITORY`* failed."
109+ PAYLOAD=$(envsubst < "${GITHUB_ACTION_PATH}/templates/integration-test/failure.tpl")
110+ echo -e "PAYLOAD<<EOF\n$PAYLOAD\nEOF" | tee -a "$GITHUB_ENV"
111111 else
112- echo "MESSAGE_TEXT=The integration test for *`$GITHUB_REPOSITORY`* succeeded." | tee -a "$GITHUB_ENV"
113- echo -e "MESSAGE_TEMPLATE<<EOF\n$(cat ${GITHUB_ACTION_PATH}/templates/integration-test/success.tpl)\nEOF" | tee -a "$GITHUB_ENV"
112+ export MESSAGE_TEXT="The integration test for *`$GITHUB_REPOSITORY`* succeeded."
113+ PAYLOAD=$(envsubst < "${GITHUB_ACTION_PATH}/templates/integration-test/success.tpl")
114+ echo -e "PAYLOAD<<EOF\n$PAYLOAD\nEOF" | tee -a "$GITHUB_ENV"
114115 fi
115116 fi
116117
117118 - name : Send Notification
118119 id : send-notification
119120 uses : slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # 2.1.1
120- env :
121- SLACK_THREAD_YAML : |
122- ${{ steps.retrieve-slack-thread-id.outcome == 'success' && format('thread_ts: "{0}"', env.SLACK_THREAD_ID) || '' }}
123- CHANNEL_ID : ${{ inputs.channel-id }}
124121 with :
125122 method : chat.postMessage
126123 token : ${{ inputs.slack-token }}
127- payload : ${{ env.MESSAGE_TEMPLATE }}
128- payload-templated : true
124+ payload : ${{ env.PAYLOAD }}
125+ payload-templated : false
129126
130127 - name : Save Slack Thread ID to File
131128 if : steps.retrieve-slack-thread-id.outcome == 'failure'
0 commit comments