Notify Mattermost #82
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: | |
inputs: | |
notify_sdk: | |
type: boolean | |
description: Notify SDK | |
default: false | |
release_version: | |
type: string | |
description: SDK tag version to use | |
default: mikroSDK-2.11.3 | |
notify_components: | |
type: boolean | |
description: Notify Boards/Cards | |
default: false | |
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: Cache Python packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytz | |
pip install requests | |
pip install py7zr | |
pip install chardet | |
pip install beautifulsoup4 | |
pip install markdown | |
- name: Build SDK Message with Python | |
if: ${{ github.event.inputs.notify_sdk == 'true' }} | |
run: | | |
python -u scripts/build_message_sdk.py "${{ github.event.inputs.release_version }}" > message.txt | |
- name: Send SDK notification to Mattermost | |
if: ${{ github.event.inputs.notify_sdk == 'true' }} | |
env: | |
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} | |
run: | | |
MESSAGE=$(cat message.txt | jq -Rs .) | |
curl -X POST -H 'Content-Type: application/json' \ | |
--data "{\"text\": $MESSAGE}" \ | |
$MATTERMOST_WEBHOOK_URL | |
- name: Build Boards/Cards Message with Python | |
if: ${{ github.event.inputs.notify_components == 'true' }} | |
run: | | |
python -u scripts/build_message.py > message.txt | |
- name: Send Boards/Cards notification to Mattermost | |
if: ${{ github.event.inputs.notify_components == 'true' }} | |
env: | |
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} | |
run: | | |
MESSAGE=$(cat message.txt) | |
curl -X POST -H 'Content-Type: application/json' \ | |
--data "{\"text\": \"$MESSAGE\"}" \ | |
$MATTERMOST_WEBHOOK_URL |