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: Trigger Target Workflow | |
on: | |
push: | |
branches: | |
- develop | |
paths: | |
- 'doc/man1/**' | |
- 'doc/man7/**' | |
jobs: | |
trigger: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: Trigger Workflow in Another Repository | |
run: | | |
# Set the required variables | |
repo_owner="mattsmida" | |
repo_name="ti.net" | |
event_type="trigger-workflow" | |
service="the-push-service" | |
version="v0.0.3" | |
# Initialize an empty array to store file contents | |
file_contents=() | |
# Iterate over changed files and read their contents | |
while IFS= read -r file; do | |
content=$(cat "$file") | |
file_contents+=("{\"name\": \"$file\", \"content\": \"$content\"}") | |
done <<< "$(git diff --name-only HEAD~1)" | |
# Convert the array to JSON | |
file_contents_json=$(printf "%s" "${file_contents[@]}") | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \ | |
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"service\": \"$service\", \"version\": \"$version\", \"unit\": false, \"integration\": true, \"files\": $file_contents_json}" |