Last active
May 29, 2023 18:19
-
-
Save GuillaumeFalourd/e31498420293305a6139b521901e1c5b to your computer and use it in GitHub Desktop.
Example triggerring a github action workflow from another repository using a repository_dispatch configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Initiator | |
on: | |
schedule: | |
- cron: '0 1 * * MON-FRI' # Runs at 1:00 UTC | |
repository_dispatch: | |
jobs: | |
producer: | |
if: github.event.action != 'Workflow Response' | |
runs-on: ubuntu-latest | |
steps: | |
- name: INIT REMOTE WORKFLOW | |
run: | | |
curl -X POST https://api.github.com/repos/<OWNER>/<REPO>/dispatches \ | |
-H 'Accept: application/vnd.github.everest-preview+json' \ | |
-u ${{ secrets.ACCESS_TOKEN }} \ | |
--data '{"event_type": "Start Workflow", "client_payload": { "repo": "'"$GITHUB_REPOSITORY"'" }}' | |
receiver: | |
if: github.event.action == 'Workflow Response' | |
runs-on: ubuntu-latest | |
steps: | |
- name: RESPONSE REMOTE WORKFLOW | |
run: echo "RESPONSE received from '${{ github.event.client_payload.repository }}'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Remote Workflow | |
on: [repository_dispatch] | |
jobs: | |
receiver: | |
runs-on: ubuntu-latest | |
if: github.event.action == 'Start Workflow' | |
steps: | |
- name: Event Information | |
run: | | |
echo "Event '${{ github.event.action }}' received from '${{ github.event.client_payload.repository }}'" | |
producer: | |
needs: [receiver] | |
runs-on: ubuntu-latest | |
steps: | |
- name: RESPONSE INIT WORKFLOW | |
run: | | |
curl -X POST https://api.github.com/repos/<OWNER>/<REPO>/dispatches \ | |
-H 'Accept: application/vnd.github.everest-preview+json' \ | |
-u ${{ secrets.ACCESS_TOKEN }} \ | |
--data '{"event_type": "Workflow Response", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment