forked from smartcontractkit/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththisdot-actions-auto-trigger.yml
More file actions
96 lines (79 loc) · 3.32 KB
/
Copy paththisdot-actions-auto-trigger.yml
File metadata and controls
96 lines (79 loc) · 3.32 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: This Dot Labs Github Actions Auto Trigger
on:
push:
branches: [main]
paths: ['src/**']
jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.THIS_DOT_GITHUB_APP_ID }}
private-key: ${{ secrets.THIS_DOT_GITHUB_APP_PRIVATE_KEY }}
owner: "thisdot"
repositories: "chainlink-webflow-cms-api"
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
run: |
echo "Getting changed files in SRC folder..."
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '^src/' | jq -R -s -c 'split("\n")[:-1]')
echo "Changed files: $CHANGED_FILES"
echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT
- name: Display dispatch payload
if: steps.changed-files.outputs.files != '[]'
run: |
echo "Changed Files: ${{ steps.changed-files.outputs.files }}"
- name: Trigger CMS Repo Github Action - cms_automation
if: steps.changed-files.outputs.files != '[]'
env:
FILES: ${{ steps.changed-files.outputs.files }}
run: |
echo "Triggering repo-b notification..."
PAYLOAD=$(jq -n \
--arg files "$FILES" \
'{ref: "main", inputs: {changed_files: $files}}')
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
https://api.github.com/repos/thisdot/chainlink-webflow-cms-api/actions/workflows/cms_automation_1.yml/dispatches \
-d "$PAYLOAD")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$RESPONSE" | head -n -1)
echo "HTTP Status Code: $HTTP_CODE"
echo "Response Body: $RESPONSE_BODY"
if [ "$HTTP_CODE" -eq 204 ]; then
echo "✅ Dispatch sent successfully!"
else
echo "❌ Dispatch failed with status code: $HTTP_CODE"
echo "Response: $RESPONSE_BODY"
exit 1
fi
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
https://api.github.com/repos/thisdot/chainlink-webflow-cms-api/actions/workflows/update_algolia_json.yml/dispatches \
-d "$PAYLOAD")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$RESPONSE" | head -n -1)
echo "HTTP Status Code: $HTTP_CODE"
echo "Response Body: $RESPONSE_BODY"
if [ "$HTTP_CODE" -eq 204 ]; then
echo "✅ Dispatch sent successfully!"
else
echo "❌ Dispatch failed with status code: $HTTP_CODE"
echo "Response: $RESPONSE_BODY"
exit 1
fi
- name: No changes detected
if: steps.changed-files.outputs.files == '[]'
run: |
echo "ℹ️ No changes detected in SRC folder. Skipping dispatch."