Skip to content

Commit 2c2d107

Browse files
committed
Automation-test
1 parent 0ad6bc7 commit 2c2d107

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: This Dot Labs Github Actions Auto Trigger
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths: ['src/**']
7+
8+
jobs:
9+
dispatch:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Generate GitHub App token
14+
id: app-token
15+
uses: actions/create-github-app-token@v1
16+
with:
17+
app-id: ${{ secrets.THIS_DOT_GITHUB_APP_ID }}
18+
private-key: ${{ secrets.THIS_DOT_GITHUB_APP_PRIVATE_KEY }}
19+
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
25+
- name: Get changed files
26+
id: changed-files
27+
run: |
28+
echo "Getting changed files in data folder..."
29+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '^data/' | jq -R -s -c 'split("\n")[:-1]')
30+
echo "Changed files: $CHANGED_FILES"
31+
echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT
32+
33+
- name: Display dispatch payload
34+
if: steps.changed-files.outputs.files != '[]'
35+
run: |
36+
echo "Changed Files: ${{ steps.changed-files.outputs.files }}"
37+
38+
- name: Trigger CMS Repo Github Action - cms_automation
39+
if: steps.changed-files.outputs.files != '[]'
40+
env:
41+
FILES: ${{ steps.changed-files.outputs.files }}
42+
run: |
43+
echo "Triggering repo-b notification..."
44+
45+
PAYLOAD=$(jq -n \
46+
--arg files "$FILES" \
47+
'{ref: "main", inputs: {changed_files: $files}}')
48+
49+
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
50+
-H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" \
51+
-H "Accept: application/vnd.github.v3+json" \
52+
-H "Content-Type: application/json" \
53+
https://api.github.com/repos/thisdot/chainlink-webflow-cms-api/actions/workflows/cms_automation_1.yml/dispatches \
54+
-d "$PAYLOAD")
55+
56+
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
57+
RESPONSE_BODY=$(echo "$RESPONSE" | head -n -1)
58+
59+
echo "HTTP Status Code: $HTTP_CODE"
60+
echo "Response Body: $RESPONSE_BODY"
61+
62+
if [ "$HTTP_CODE" -eq 204 ]; then
63+
echo "✅ Dispatch sent successfully!"
64+
else
65+
echo "❌ Dispatch failed with status code: $HTTP_CODE"
66+
echo "Response: $RESPONSE_BODY"
67+
exit 1
68+
fi
69+
70+
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
71+
-H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" \
72+
-H "Accept: application/vnd.github.v3+json" \
73+
-H "Content-Type: application/json" \
74+
https://api.github.com/repos/thisdot/chainlink-webflow-cms-api/actions/workflows/update_algolia_json.yml/dispatches \
75+
-d "$PAYLOAD")
76+
77+
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
78+
RESPONSE_BODY=$(echo "$RESPONSE" | head -n -1)
79+
80+
echo "HTTP Status Code: $HTTP_CODE"
81+
echo "Response Body: $RESPONSE_BODY"
82+
83+
if [ "$HTTP_CODE" -eq 204 ]; then
84+
echo "✅ Dispatch sent successfully!"
85+
else
86+
echo "❌ Dispatch failed with status code: $HTTP_CODE"
87+
echo "Response: $RESPONSE_BODY"
88+
exit 1
89+
fi
90+
91+
- name: No changes detected
92+
if: steps.changed-files.outputs.files == '[]'
93+
run: |
94+
echo "ℹ️ No changes detected in data folder. Skipping dispatch."

0 commit comments

Comments
 (0)