From f6c837a08236b7e1fcac6fc01318c6fcd0e8fa0b Mon Sep 17 00:00:00 2001 From: Abdur-Rahman Fashola Date: Sat, 27 Jan 2024 15:51:20 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=99=20Brought=20`workflow=5Fdispatch`?= =?UTF-8?q?=20trigger=20back?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/s3-trigger.yml | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/s3-trigger.yml diff --git a/.github/workflows/s3-trigger.yml b/.github/workflows/s3-trigger.yml new file mode 100644 index 0000000..18ec2cc --- /dev/null +++ b/.github/workflows/s3-trigger.yml @@ -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\"}" +