Notify Mattermost #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Notify Mattermost | |
on: | |
workflow_dispatch: | |
jobs: | |
notify: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Build Message with Python | |
id: build_message | |
run: | | |
MATTERMOST_MESSAGE=$(python -u scripts/build_message.py) | |
# Escape newlines and quotes for JSON compatibility | |
MATTERMOST_MESSAGE_ESCAPED=$(echo "$MATTERMOST_MESSAGE" | jq -R .) | |
echo "MATTERMOST_MESSAGE=$MATTERMOST_MESSAGE_ESCAPED" >> $GITHUB_ENV | |
- name: Send notification to Mattermost | |
env: | |
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} | |
MATTERMOST_MESSAGE: ${{ env.MATTERMOST_MESSAGE }} | |
run: | | |
curl -X POST -H 'Content-Type: application/json' \ | |
--data "{\"text\": $MATTERMOST_MESSAGE}" \ | |
$MATTERMOST_WEBHOOK_URL |