-
Notifications
You must be signed in to change notification settings - Fork 3
71 lines (63 loc) · 2.68 KB
/
webhook-handler.yml
File metadata and controls
71 lines (63 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Webhook Handler for AlphaDroid-devices/OTA
# This file should be placed in the .github/workflows/ directory of the OTA repository
name: Notify Website of Updates
on:
push:
branches: [master, main]
paths: ['*.json']
jobs:
notify:
runs-on: ubuntu-latest
if: github.repository == 'AlphaDroid-devices/OTA'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2 # Need previous commit to compare changes
- name: Get changed files
id: changes
run: |
# Get list of changed files in this push
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT
# Check if any JSON files were changed
if echo "$CHANGED_FILES" | grep -q "\.json$"; then
echo "has_json_changes=true" >> $GITHUB_OUTPUT
echo "event_type=ota-device-update" >> $GITHUB_OUTPUT
echo "Found JSON file changes, will trigger device update"
else
echo "has_json_changes=false" >> $GITHUB_OUTPUT
echo "event_type=ota-update" >> $GITHUB_OUTPUT
echo "No JSON file changes detected"
fi
# Log the changes for debugging
echo "Changed files:"
echo "$CHANGED_FILES"
- name: Trigger website update
if: steps.changes.outputs.has_json_changes == 'true'
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: alphadroid-project/alphadroid-project.github.io
event-type: ${{ steps.changes.outputs.event_type }}
client-payload: |
{
"changed_files": "${{ steps.changes.outputs.changed_files }}",
"repository": "${{ github.repository }}",
"commit": "${{ github.sha }}",
"ref": "${{ github.ref }}",
"pusher": "${{ github.actor }}",
"timestamp": "${{ github.event.head_commit.timestamp }}",
"commit_message": "${{ github.event.head_commit.message }}",
"commit_url": "${{ github.event.head_commit.url }}"
}
- name: Log notification result
run: |
if [[ "${{ steps.changes.outputs.has_json_changes }}" == "true" ]]; then
echo "✅ Successfully triggered website update"
echo "Event type: ${{ steps.changes.outputs.event_type }}"
echo "Repository: ${{ github.repository }}"
echo "Commit: ${{ github.sha }}"
else
echo "ℹ️ No JSON file changes detected, skipping webhook trigger"
fi