Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions .github/workflows/deploy-merged-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,38 @@ permissions:
actions: read

jobs:
check-file-changes:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
SOURCE_REPO: ${{ github.repository }}
outputs:
should_sync: ${{ steps.filter.outputs.should_sync }}
steps:
- name: Check Changed File Paths
id: filter
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXCLUDED_PATHS=(
".github/workflows/"
)

CHANGED_FILES=$(gh pr view $PR_NUMBER --json files --repo $SOURCE_REPO --jq '[.files[].path]')

EXCLUDE_FILTER=$(printf '"%s",' "${EXCLUDED_PATHS[@]}")
EXCLUDE_FILTER="[${EXCLUDE_FILTER%,}]"

NON_WORKFLOW_CHANGES=$(echo "$CHANGED_FILES" | jq --argjson exclude "$EXCLUDE_FILTER" '[.[] | select(. as $f | $exclude | any(. as $p | $f | startswith($p)) | not)] | length')
if [ "$NON_WORKFLOW_CHANGES" -gt 0 ]; then
echo "PR contains changes outside filtered paths — proceeding."
echo "should_sync=true" >> $GITHUB_OUTPUT
else
echo "All changes are under filtered paths — skipping workflow."
echo "should_sync=false" >> $GITHUB_OUTPUT
fi

check-merge-state:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -95,8 +127,8 @@ jobs:
echo "Auto-merge enabled successfully!"

dispatch-to-internal:
needs: check-merge-state
if: needs.check-merge-state.outputs.checks_passed == 'true' && github.event.review.state == 'approved'
needs: [check-file-changes, check-merge-state]
if: needs.check-merge-state.outputs.checks_passed == 'true' && needs.check-file-changes.outputs.should_sync == 'true' && github.event.review.state == 'approved'
runs-on: ubuntu-latest
env:
SOURCE_REPO: github/github-well-architected
Expand Down
Loading