Moved to using API via GH CLI for custom payload data delivery instea… #6
Workflow file for this run
This file contains hidden or 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: Trigger Target Workflow | |
| on: | |
| push: | |
| branches: | |
| - "att/**" | |
| workflow_dispatch: | |
| jobs: | |
| trigger: | |
| runs-on: | |
| group: "FlexCloud-Rocky" | |
| env: | |
| target_owner: "${{ secrets.TARGET_OWNER }}" | |
| target_name: "${{ secrets.TARGET_NAME }}" | |
| target_workflow: "${{ secrets.TARGET_WORKFLOW }}" | |
| event_type: "${{ secrets.TARGET_EVENT_TYPE }}" | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - name: Install DNF Config Manager | |
| run: | | |
| sudo dnf -y install 'dnf-command(config-manager)' | |
| - name: Install GitHub CLI | |
| run: | | |
| sudo dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo | |
| sudo dnf -y install gh | |
| - name: Install gettext (for envsubvst) | |
| run: | | |
| sudo dnf -y install gettext | |
| - name: Install YQ | |
| run: | | |
| sudo curl -L -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
| sudo chmod a+x /usr/local/bin/yq | |
| - name: Authenticate GitHub CLI Using Access Token | |
| run: | | |
| echo "${{ secrets.TARGET_REPOSITORY_ACCESS_TOKEN }}" | gh auth login --with-token | |
| gh auth status | |
| - name: Trigger Workflow in Target Repository (api) | |
| run: | | |
| event_data=$(cat <<EOM | yq -o json -I 0 '.' | |
| event_type: "${{ env.event_type }}" | |
| client_payload: | |
| reference: | |
| name: "${{ github.ref_name }}" | |
| ref: "${{ github.ref }}" | |
| type: "${{ github.ref_type }}" | |
| sha: "${{ github.sha }}" | |
| repository: | |
| name: "${{ github.repository }}" | |
| url: "${{ github.repositoryUrl }}" | |
| run: | |
| id: "${{ github.run_id }}" | |
| iteration: "${{ github.run_number }}" | |
| workflow: | |
| name: "${{ github.workflow }}" | |
| ref: "${{ github.workflow_ref }}" | |
| sha: "${{ github.workflow_sha }}" | |
| EOM | |
| ) | |
| echo "${event_data}" | \ | |
| gh api --verbose \ | |
| -X POST \ | |
| --input - \ | |
| /repos/${{ env.target_owner }}/${{ env.target_name }}/dispatches \ | |
| ; |