File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 branches :
66 - " att/**"
77 workflow_dispatch :
8+ inputs :
9+ trigger-type :
10+ description : " How to trigger the target workflow"
11+ required : true
12+ type : choice
13+ options :
14+ - api
15+ - workflow-run
816
917jobs :
1018 trigger :
4351 echo "${{ secrets.TARGET_REPOSITORY_ACCESS_TOKEN }}" | gh auth login --with-token
4452 gh auth status
4553
54+ # Triggering workflows via the API is meant to be used by external systems.
4655 - name : Trigger Workflow in Target Repository (api)
56+ if : " ${{ github.event.inputs.trigger-type == 'api'}}"
4757 run : |
4858 event_data=$(cat <<EOM | yq -o json -I 0 '.'
4959 event_type: "${{ env.event_type }}"
7181 --input - \
7282 /repos/${{ env.target_owner }}/${{ env.target_name }}/dispatches \
7383 ;
84+
85+ # Triggering workflows via workflow execution is preferred when within the GitHub ecosystem.
86+ - name : Trigger Workflow in Target Repository (workflow run)
87+ if : " ${{ github.event.inputs.trigger-type == 'workflow-run' }}"
88+ run : |
89+ gh workflow run \
90+ ${{ env.target_workflow }} \
91+ --repo ${{ env.target_owner }}/${{ env.target_name }} \
92+ --ref main \
93+ --field branch-name=${{ github.ref_name }} \
94+ ;
You can’t perform that action at this time.
0 commit comments