Skip to content

main-workflow-initiate #22

main-workflow-initiate

main-workflow-initiate #22

name: Target Repository Workflow
on:
repository_dispatch:
types: [main-workflow-initiate]
jobs:
main-workflow:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Trigger the main workflow
run: |
WORKFLOW_ID=$(curl -s -H "Authorization: token ${TOKEN}" \
"https://api.github.com/repos/umasad087/RepoA/actions/workflows/trigger-and-wait.yml" \
| jq -r '.id')
curl -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/umasad087/RepoA/actions/workflows/$WORKFLOW_ID/dispatches" \
-d '{\"event_type\": \"main-workflow\","ref": "main", "inputs": {}}'
echo "Triggered by user: ${{ github.event.client_payload.username }}"
echo "From repository: ${{ github.event.client_payload.repo_url }}"
echo "With commit message: ${{ github.event.client_payload.commit_message }}"
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}