-
-
Notifications
You must be signed in to change notification settings - Fork 1
37 lines (32 loc) · 1.09 KB
/
dispatcher.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: Delayed Trigger
on:
push:
branches:
- main # change to `docs` later
jobs:
wait-and-trigger:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: 5️⃣ Wait for 5 seconds
run: sleep 5
- name: 🔀 Check for newer commits
id: check-commits
run: |
LATEST_COMMIT=$(git log -1 --format='%H')
CURRENT_COMMIT=${{ github.sha }}
if [ "$LATEST_COMMIT" != "$CURRENT_COMMIT" ]; then
echo "Newer commit found. Stopping workflow."
echo "::set-output name=stop::true"
fi
- name: ⚡ Trigger main workflow
if: steps.check-commits.outputs.stop != 'true'
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/sync-s3-posts.yml/dispatches \
-d "{\"ref\":\"main\"}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}