Skip to content

Commit

Permalink
👷: Discord Notification
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPLukaas committed May 30, 2024
1 parent 26bc077 commit 053a903
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,15 @@ workflows:
# Note that you don't need to include title and changelog if you do not want to.
# Any number of artifacts can be included with the release.
- name: Discord notification
script: |
set -ex
APP_LINK=$(echo $CM_ARTIFACT_LINKS | jq -r '.[] | select(.name=="app.aab") | .url')
# Get first 7 digits of commit number
COMMIT=$(echo "${CM_COMMIT}" | sed 's/^\(........\).*/\1/;q')
# Get commit message
COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT)
# Get commit author
AUTHOR=$(git show -s --format='%ae' $CM_COMMIT)
# Publish the notification
curl -H "Content-Type: multipart/form-data" \
-F 'payload_json={"username" : "codemagic-bot", "content": "**Commit:** `'"$COMMIT"'`\n\n**Commit message:** '"$COMMIT_MESSAGE"'\n\n**Branch:** '"$CM_BRANCH"'\n\n**Author:** '"$AUTHOR"'\n\n**Artifacts: **\n\n'"$APP_LINK"'\n\n"}' \
$WEBHOOK_URL
- name: Create a changelog
script: |
if [[ -z ${CM_PREVIOUS_COMMIT} ]]
then
echo "No finished builds found to generate changelog" | tee release_notes.txt
else
echo "$(git-changelog generate --previous-commit $CM_PREVIOUS_COMMIT)" | tee release_notes.txt
fi
artifacts:
- build/**/outputs/**/*.aab
- build/**/outputs/**/mapping.txt
Expand All @@ -86,4 +77,24 @@ workflows:
- [email protected]
notify:
success: true
failure: true
failure: true
scripts:
- name: Discord notification
script: |
set -ex
APP_LINK=$(echo $CM_ARTIFACT_LINKS | jq -r '.[] | select(.name=="app.aab") | .url')
# Get first 7 digits of commit number
COMMIT=$(echo "${CM_COMMIT}" | sed 's/^\(........\).*/\1/;q')
# Get commit message
COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT)
# Get commit author
AUTHOR=$(git show -s --format='%ae' $CM_COMMIT)
# Publish the notification
curl -H "Content-Type: multipart/form-data" \
-F 'payload_json={"username" : "codemagic-bot", "content": "**Commit:** `'"$COMMIT"'`\n\n**Commit message:** '"$COMMIT_MESSAGE"'\n\n**Branch:** '"$CM_BRANCH"'\n\n**Author:** '"$AUTHOR"'\n\n**Artifacts: **\n\n'"$APP_LINK"'\n\n"}' \
-F "file1=@release_notes.txt" \
$WEBHOOK_URL

0 comments on commit 053a903

Please sign in to comment.