-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (31 loc) · 1.13 KB
/
main.yml
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
name: Trigger Target Repository Workflow
on:
push:
branches:
- main
- stage
- testing
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Trigger Target Repository
run: |
BRANCH_NAME=${GITHUB_REF##*/}
echo "Triggering deployment for branch: $BRANCH_NAME"
# Make the API request and capture the response code
RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X POST \
-H "Authorization: token ${{ secrets.DEPLOY_PAT }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
https://api.github.com/repos/navnorth/wp-nn-dot-com/dispatches \
-d "{\"event_type\": \"trigger-sync-theme\", \"client_payload\": {\"branch\": \"$BRANCH_NAME\"}}")
echo "API Response Code: $RESPONSE"
cat response.json
# Exit with non-zero status if the response is 404
if [ "$RESPONSE" -eq 404 ]; then
echo "Error: Repository not found (404)"
exit 1
elif [ "$RESPONSE" -eq 422 ]; then
echo "Error: Validation failed, or the endpoint has been spammed. (404)"
exit 1
fi