2 # Usage: ./slack-notify.sh {title} ({description}:{job_id})...
4 # Determine the current state based on whether we are triggered
5 # from a tag, commit, or manually for testing purposes. If there
6 # is no CI_COMMIT_TAG, then use the latest commit in the pipeline.
7 CURRENT_STATE
=${CI_COMMIT_TAG:-${CI_COMMIT_SHORT_SHA:-$(git rev-parse --short HEAD)}}
14 \"type\": \"plain_text\",
16 \"text\": \":protonpass: $1 [$CURRENT_STATE]\"
21 for arg
in "${@:2}"; do # Skip first {title} argument
22 IFS
=':' read -r description jobid
<<<"$arg"
24 # Add a section block for each job
27 \"type\": \"section\",
30 \"text\": \"*${description}*: <${CI_PROJECT_URL}/-/jobs/${jobid}/artifacts/download|Download> (expires in 1 week)\"
37 SLACK_POST_BODY
=$
(echo "{
38 \"channel\": \"$PASS_EXTENSION_BUILD_SLACK_CHANNEL_ID\",
43 -X POST https
://slack.com
/api
/chat.postMessage \
44 -H "Content-type: application/json; charset=utf-8" \
45 -H "Authorization: Bearer ${SIMPLE_LOGIN_SLACK_BOT_TOKEN}" \
46 --data-raw "$SLACK_POST_BODY"