Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/send-notifications.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

JSON_PAYLOAD=$(cat <<EOF
{
"application": "PES",
"sys_name": "WooCommerce $ACTION_NAME",
"deployer": "$PUSHER_NAME",
"files_changed_count": $(echo git show --name-only --format= $GITHUB_SHA | wc -l),
"last_commit_message": $(echo -n "$COMMIT_MESSAGE" | jq -Rsa 'tojson'),
"last_commit_hash": "$GITHUB_SHA",
"timestamp": "$(date --utc +%Y-%m-%dT%H:%M:%SZ)"
}
EOF
)

curl -sS -X POST \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
"$WEBHOOK_URL" > /dev/null
13 changes: 13 additions & 0 deletions .github/workflows/run-notification-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: run notifications

on:
release:
types: [published]

jobs:
call-reusable-workflow:
uses: ./.github/workflows/send-notification-reusable.yml
with:
action_name: Released to main
secrets:
webhook_url: ${{ secrets.DEPLOYMENT_WEBHOOK_URL_PROD }}
13 changes: 13 additions & 0 deletions .github/workflows/run-notification-prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: run notifications

on:
push:
branches: [pre-release]

jobs:
call-reusable-workflow:
uses: ./.github/workflows/send-notification-reusable.yml
with:
action_name: Pushed to pre-release
secrets:
webhook_url: ${{ secrets.DEPLOYMENT_WEBHOOK_URL_STAGE }}
30 changes: 30 additions & 0 deletions .github/workflows/send-notification-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Send Notification Reusable

on:
workflow_call:
inputs:
action_name:
required: true
type: string
secrets:
webhook_url:
required: true

jobs:
sendNotifications:
name: "Send MS-teams notification"
runs-on: ubuntu-24.04
steps:
- name: "Init env variables"
run: |
echo "WEBHOOK_URL=${{ secrets.webhook_url }}" >> $GITHUB_ENV
echo "ACTION_NAME='${{ inputs.action_name }}'" >> $GITHUB_ENV
echo "PUSHER_NAME=${{ github.event.pusher.name }}" >> $GITHUB_ENV
echo "COMMIT_MESSAGE=${{ github.event.head_commit.message }}" >> $GITHUB_ENV
echo "GITHUB_SHA=${{ github.sha }}" >> $GITHUB_ENV
- name: "Init dependency"
uses: actions/checkout@v4
- name: "Send notifications"
shell: bash
run: |
${GITHUB_WORKSPACE}/.github/send-notifications.sh