Skip to content

Commit

Permalink
feat: call mirror repo to trigger on each merge to main (#225)
Browse files Browse the repository at this point in the history
* feat: call mirror repo to trigger on each merge to main

* trigger on all pushes

* add manual trigger

* submit branch name

* fix syntax error

* log branch name

* update client_payload

---------

Co-authored-by: Philip Germanov <[email protected]>
Co-authored-by: Jordi van Liempt <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2024
1 parent 507c441 commit f01a8e3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Trigger Mirror

on:
push:
workflow_dispatch:

permissions:
contents: read

jobs:
trigger_mirror:
name: Trigger Mirror Workflow
runs-on: ubuntu-latest
steps:
- name: Trigger mirror workflow
run: |
echo "branch name: ${{ github.head_ref || github.ref_name }}"
response=$(curl -L \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.MIRROR_WORKFLOW_TOKEN }}" \
-w "%{http_code}" \
--max-time 30 \
"${{ secrets.MIRROR_API_URL }}/dispatches" \
-d '{"event_type":"mirror_trigger","client_payload":{"source_repo":"https://github.com/${{ github.repository }}", "source_branch":"${{ github.head_ref || github.ref_name }}"}}')
status_code=${response: -3}
if [ "$status_code" -ne 204 ]; then
echo "Failed to trigger mirror workflow. Status code: $status_code"
exit 1
fi

0 comments on commit f01a8e3

Please sign in to comment.