Skip to content

Commit

Permalink
fix: using git diff
Browse files Browse the repository at this point in the history
  • Loading branch information
sambhavgupta0705 committed Dec 16, 2024
1 parent e230dde commit 9b5d530
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions .github/workflows/notify-triager.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Notify Triagers

on:
pull_request_target:
pull_request:
types: [opened, reopened, synchronize, edited, ready_for_review]

jobs:
Expand All @@ -11,8 +11,7 @@ jobs:
- name: Checkout Repository
uses: actions/[email protected]
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Get commit message
id: commit-message
Expand All @@ -34,21 +33,27 @@ jobs:
echo "isMergeCommit=false" >> $GITHUB_OUTPUT
fi
- name: Checkout asyncapi/website Repository
uses: actions/[email protected]
- name: Count changed files
id: changed_files
run: |
# Get the list of files changed in the latest commit
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
- name: Get all changed files
id: changed-files
uses: tj-actions/changed-files@v45
# Initialize counters
md_count=0
non_md_count=0
- name: Check PR Changes for .md files
id: md-pr-changes
uses: tj-actions/changed-files@v45 # version 42.1.0 https://github.com/tj-actions/changed-files/releases/tag/v42.1.0
with:
files: |
**.md
# Loop through the changed files to count .md and non-.md files
for file in $changed_files; do
if [[ $file == *.md ]]; then
md_count=$((md_count + 1))
else
non_md_count=$((non_md_count + 1))
fi
done
echo "md_count=$md_count" >> $GITHUB_OUTPUT
echo "non_md_count=$non_md_count" >> $GITHUB_OUTPUT
- name: Extract Doc Triage Maintainers
id: doc-triager
Expand All @@ -69,7 +74,7 @@ jobs:
echo "codeTriagers=$codeTriagers" >> $GITHUB_ENV
- name: Add Reviewers for code files
if: ${{ steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.changed-files.outputs.all_changed_files_count != steps.md-pr-changes.outputs.all_changed_files_count }}
if: ${{ steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.changed_files.outputs.non_md_count > 0 }}
run: |
IFS=' ' read -r -a codeTriagers <<< "${{ env.codeTriagers }}"
reviewers=$(printf ', "%s"' "${codeTriagers[@]}")
Expand All @@ -84,7 +89,7 @@ jobs:
}"
- name: Add Reviewers for doc files
if: ${{ steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.md-pr-changes.outputs.any_changed == 'true' }}
if: ${{ steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.changed_files.outputs.md_count > 0 }}
run: |
IFS=' ' read -r -a docTriagers <<< "${{ env.docTriagers }}"
reviewers=$(printf ', "%s"' "${docTriagers[@]}")
Expand Down

0 comments on commit 9b5d530

Please sign in to comment.