Skip to content

Commit

Permalink
Trigger workflow on release instead of push, send all doc files inste…
Browse files Browse the repository at this point in the history
…ad of just changed files
  • Loading branch information
mattsmida committed Jun 3, 2024
1 parent 99354e6 commit dc58731
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/trigger-workflow-update-docs.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
name: Trigger update docs workflow on ti.net repo
on:
push:
branches:
- develop
paths:
- 'doc/man1/**'
- 'doc/man7/**'
release:
types:
- published
jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Trigger remote workflow to update docs
run: |
repo_owner="mattsmida"
repo_name="ti.net"
event_type="trigger-workflow-update-docs"
service="the-push-service"
version="v0.0.3"
changed_filenames=$(git -C $GITHUB_WORKSPACE diff --name-only HEAD~1)
version="${{ github.event.release.tag_name }}"
# Format changed_filenames with single quotes and commas
formatted_changed_filenames="[ $(echo $changed_filenames | sed "s/\S\+/\"&\",/g; s/,$//") ]"
# Collect all documentation files
doc_filenames=$(find doc/man1 doc/man7 -type f)
# Format doc_filenames with single quotes and commas
doc_filenames="[ $(echo $doc_files | sed "s/\S\+/\"&\",/g; s/,$//") ]"
base64_encoded_files=()
while IFS= read -r filename; do
base64_encoded_file=$(base64 "$filename" | tr -d '\n')
base64_encoded_files+=("\"$base64_encoded_file\"")
done <<< "$changed_filenames"
done <<< "$doc_filenames"
# Format encoded_file_contents with quotes and commas
formatted_encoded_file_contents="$(for elem in "${base64_encoded_files[@]}"; do echo "$elem,"; done)"
encoded_file_contents="$(for elem in "${base64_encoded_files[@]}"; do echo "$elem,"; done)"
formatted_encoded_file_contents="[ $(echo $formatted_encoded_file_contents | sed 's/,$//') ]"
encoded_file_contents="[ $(echo $formatted_encoded_file_contents | sed 's/,$//') ]"
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, \"changed_filenames\": $formatted_changed_filenames, \"encoded_file_contents\": $formatted_encoded_file_contents}}"
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"service\": \"$service\", \"version\": \"$version\", \"unit\": false, \"integration\": true, \"doc_filenames\": $doc_filenames, \"encoded_file_contents\": $encoded_file_contents}}"

0 comments on commit dc58731

Please sign in to comment.