Skip to content

Commit

Permalink
πŸ™ Brought workflow_dispatch trigger back
Browse files Browse the repository at this point in the history
  • Loading branch information
ShafSpecs committed Jan 27, 2024
1 parent eb5321c commit f6c837a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/s3-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ⏰ Delayed Trigger for S3 Sync

on:
push:
branches:
- docs

permissions: write-all

jobs:
wait-and-trigger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: πŸ”Ÿ Wait for 10 seconds
run: sleep 10

- 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=abort::true"
fi
- name: ⚑ Trigger main workflow
if: steps.check-commits.outputs.abort != 'true'
run: |
curl -L \
-X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/sync-s3-posts.yml/dispatches \
-d "{\"ref\":\"docs\"}"

0 comments on commit f6c837a

Please sign in to comment.