@@ -65,26 +65,48 @@ workflows:
6565 script : |
6666 set -ex
6767
68+ # Check if WEBHOOK_URL is set
69+ if [ -z "$WEBHOOK_URL" ]; then
70+ echo "Warning: WEBHOOK_URL is not set. Skipping Discord notification."
71+ echo "Please set the WEBHOOK_URL environment variable in the discord_credentials group."
72+ exit 0
73+ fi
74+
6875 # Get artifact link for the IPA file
6976 APP_LINK=$(echo $CM_ARTIFACT_LINKS | jq -r '.[] | select(.name | contains("FrameExtractionTool-unsigned.ipa")) | .url // "No artifact link available"')
7077
7178 # Get first 7 digits of commit number
7279 COMMIT=$(echo "${CM_COMMIT}" | sed 's/^\(........\).*/\1/;q')
7380
74- # Get commit message
75- COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT)
81+ # Get commit message (escape quotes and newlines for JSON)
82+ COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT | tr '\n' ' ' | sed 's/"/\\"/g' )
7683
7784 # Get commit author
7885 AUTHOR=$(git show -s --format='%ae' $CM_COMMIT)
7986
8087 # Get build status
8188 BUILD_STATUS="✅ Build Successful"
8289
90+ # Create the JSON payload
91+ PAYLOAD=$(cat <<EOF
92+ {
93+ " username " : " FrameExtractionTool-CI" ,
94+ " content " : " $BUILD_STATUS - iOS Unsigned Build\\ n\\ n**Commit:** \` $COMMIT\` \\ n\\ n**Commit message:** $COMMIT_MESSAGE\\ n\\ n**Branch:** $CM_BRANCH\\ n\\ n**Author:** $AUTHOR\\ n\\ n**Build:** $CM_BUILD_URL\\ n\\ n**Artifacts:**\\ n$APP_LINK"
95+ }
96+ EOF
97+ )
98+
8399 # Send Discord notification
84- curl -H "Content-Type: multipart/form-data" \
85- -F 'payload_json={"username" : "FrameExtractionTool-CI", "content": "'"$BUILD_STATUS"' - iOS Unsigned Build\n\n**Commit:** `'"$COMMIT"'`\n\n**Commit message:** '"$COMMIT_MESSAGE"'\n\n**Branch:** '"$CM_BRANCH"'\n\n**Author:** '"$AUTHOR"'\n\n**Build:** '"$CM_BUILD_URL"'\n\n**Artifacts:**\n'"$APP_LINK"'\n"}' \
86- -F "file1=@release_notes.txt" \
87- $WEBHOOK_URL
100+ if [ -f "release_notes.txt" ]; then
101+ curl -H "Content-Type : multipart/form-data" \
102+ -F "payload_json=$PAYLOAD" \
103+ -F "file1=@release_notes.txt" \
104+ " $WEBHOOK_URL"
105+ else
106+ curl -H "Content-Type : application/json" \
107+ -d "$PAYLOAD" \
108+ " $WEBHOOK_URL"
109+ fi
88110
89111 ios-release-workflow :
90112 name : iOS Release Build
@@ -166,6 +188,13 @@ workflows:
166188 script : |
167189 set -ex
168190
191+ # Check if WEBHOOK_URL is set
192+ if [ -z "$WEBHOOK_URL" ]; then
193+ echo "Warning: WEBHOOK_URL is not set. Skipping Discord notification."
194+ echo "Please set the WEBHOOK_URL environment variable in the discord_credentials group."
195+ exit 0
196+ fi
197+
169198 # Get version from tag
170199 VERSION=${CM_TAG#v}
171200
@@ -175,17 +204,32 @@ workflows:
175204 # Get first 7 digits of commit number
176205 COMMIT=$(echo "${CM_COMMIT}" | sed 's/^\(........\).*/\1/;q')
177206
178- # Get commit message
179- COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT)
207+ # Get commit message (escape quotes and newlines for JSON)
208+ COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT | tr '\n' ' ' | sed 's/"/\\"/g' )
180209
181210 # Get commit author
182211 AUTHOR=$(git show -s --format='%ae' $CM_COMMIT)
183212
184213 # Get build status
185214 BUILD_STATUS="🚀 Release Build Successful"
186215
216+ # Create the JSON payload
217+ PAYLOAD=$(cat <<EOF
218+ {
219+ " username " : " FrameExtractionTool-CI" ,
220+ " content " : " $BUILD_STATUS - iOS Release v$VERSION\\ n\\ n**Release Tag:** \` $CM_TAG\` \\ n\\ n**Commit:** \` $COMMIT\` \\ n\\ n**Commit message:** $COMMIT_MESSAGE\\ n\\ n**Branch:** $CM_BRANCH\\ n\\ n**Author:** $AUTHOR\\ n\\ n**Build:** $CM_BUILD_URL\\ n\\ n**Release Artifacts:**\\ n$APP_LINK"
221+ }
222+ EOF
223+ )
224+
187225 # Send Discord notification
188- curl -H "Content-Type: multipart/form-data" \
189- -F 'payload_json={"username" : "FrameExtractionTool-CI", "content": "'"$BUILD_STATUS"' - iOS Release v'"$VERSION"'\n\n**Release Tag:** `'"$CM_TAG"'`\n\n**Commit:** `'"$COMMIT"'`\n\n**Commit message:** '"$COMMIT_MESSAGE"'\n\n**Branch:** '"$CM_BRANCH"'\n\n**Author:** '"$AUTHOR"'\n\n**Build:** '"$CM_BUILD_URL"'\n\n**Release Artifacts:**\n'"$APP_LINK"'\n"}' \
190- -F "file1=@release_notes.txt" \
191- $WEBHOOK_URL
226+ if [ -f "release_notes.txt" ]; then
227+ curl -H "Content-Type : multipart/form-data" \
228+ -F "payload_json=$PAYLOAD" \
229+ -F "file1=@release_notes.txt" \
230+ " $WEBHOOK_URL"
231+ else
232+ curl -H "Content-Type : application/json" \
233+ -d "$PAYLOAD" \
234+ " $WEBHOOK_URL"
235+ fi
0 commit comments