add auto reloading configs #8
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: "PR Orphaned Diff Finder" | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
orphaned-diff: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout the PR | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate Final PR Diff | |
id: final_diff | |
run: | | |
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > final_diff.patch | |
echo "Final diff generated." | |
- name: Identify Orphaned Changes | |
id: orphaned_changes | |
run: | | |
echo "## Orphaned Changes" > orphaned_changes.md | |
# Fetch the base and head refs | |
git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }} | |
git fetch origin ${{ github.event.pull_request.head.ref }}:${{ github.event.pull_request.head.ref }} | |
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > final_diff.patch | |
echo "## Orphaned Changes" > orphaned_changes.md | |
commits=$(git log ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} --pretty=format:"%H" --reverse) | |
any_orphaned=false | |
for commit in $commits; do | |
echo "Checking commit $commit..." | |
git diff ${commit}^ $commit > commit_diff.patch || true | |
# Compare commit diff with final diff | |
ORPHANED=$(diff --unchanged-line-format='' --old-line-format='%L' --new-line-format='' commit_diff.patch final_diff.patch | grep -Ev '^@@' || true) | |
if [[ ! -z "$ORPHANED" ]]; then | |
echo "### Commit $commit" >> orphaned_changes.md | |
echo "" >> orphaned_changes.md | |
echo "<details>" >> orphaned_changes.md | |
echo "<summary>View Orphaned Changes</summary>" >> orphaned_changes.md | |
echo "" >> orphaned_changes.md | |
echo '```diff' >> orphaned_changes.md | |
echo "$ORPHANED" >> orphaned_changes.md | |
echo '```' >> orphaned_changes.md | |
echo "" >> orphaned_changes.md | |
echo "</details>" >> orphaned_changes.md | |
echo "" >> orphaned_changes.md | |
any_orphaned=true | |
fi | |
done | |
if [[ "$any_orphaned" = false ]]; then | |
echo "No orphaned changes found." | |
echo "No orphaned changes found." > orphaned_changes.md | |
fi | |
- name: Comment on PR with Orphaned Changes | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: orphaned-diff | |
path: orphaned_changes.md |