From 00d34c326cbff0cfed139234287959b6fff66b4f Mon Sep 17 00:00:00 2001 From: Kitty Chiu <42864823+KittyChiu@users.noreply.github.com> Date: Wed, 6 May 2026 11:20:35 +1000 Subject: [PATCH 1/4] feat: Added filter to CD --- .github/workflows/deploy-merged-pr.yml | 35 +++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-merged-pr.yml b/.github/workflows/deploy-merged-pr.yml index 8205dad..df93a1c 100644 --- a/.github/workflows/deploy-merged-pr.yml +++ b/.github/workflows/deploy-merged-pr.yml @@ -11,9 +11,42 @@ permissions: actions: read jobs: - check-merge-state: + 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_run: ${{ steps.filter.outputs.should_run }} + 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 .github/workflows/ — proceeding." + echo "should_run=true" >> $GITHUB_OUTPUT + else + echo "All changes are under .github/workflows/ — skipping workflow." + echo "should_run=false" >> $GITHUB_OUTPUT + fi + + check-merge-state: + needs: check-file-changes + if: needs.check-file-changes.outputs.should_run == 'true' + runs-on: ubuntu-latest env: PR_NUMBER: ${{ github.event.pull_request.number }} SOURCE_REPO: ${{ github.repository }} From 0349ca65849fbbe610ad467e4c694d7ecc6e4ffa Mon Sep 17 00:00:00 2001 From: Kitty Chiu <42864823+KittyChiu@users.noreply.github.com> Date: Wed, 6 May 2026 11:32:44 +1000 Subject: [PATCH 2/4] feat: restructured jobs --- .github/workflows/deploy-merged-pr.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-merged-pr.yml b/.github/workflows/deploy-merged-pr.yml index df93a1c..98bd8ab 100644 --- a/.github/workflows/deploy-merged-pr.yml +++ b/.github/workflows/deploy-merged-pr.yml @@ -44,8 +44,7 @@ jobs: fi check-merge-state: - needs: check-file-changes - if: needs.check-file-changes.outputs.should_run == 'true' + if: github.event.review.state == 'approved' runs-on: ubuntu-latest env: PR_NUMBER: ${{ github.event.pull_request.number }} @@ -128,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_run == 'true' && github.event.review.state == 'approved' runs-on: ubuntu-latest env: SOURCE_REPO: github/github-well-architected From 9f23cdbabf71b05327fc6a896dbf0a166cfc9fbc Mon Sep 17 00:00:00 2001 From: Kitty Chiu <42864823+KittyChiu@users.noreply.github.com> Date: Wed, 6 May 2026 11:55:43 +1000 Subject: [PATCH 3/4] updated variable name and messages --- .github/workflows/deploy-merged-pr.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-merged-pr.yml b/.github/workflows/deploy-merged-pr.yml index 98bd8ab..69ef39b 100644 --- a/.github/workflows/deploy-merged-pr.yml +++ b/.github/workflows/deploy-merged-pr.yml @@ -18,7 +18,7 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} SOURCE_REPO: ${{ github.repository }} outputs: - should_run: ${{ steps.filter.outputs.should_run }} + should_sync: ${{ steps.filter.outputs.should_sync }} steps: - name: Check Changed File Paths id: filter @@ -36,11 +36,11 @@ jobs: 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 .github/workflows/ — proceeding." - echo "should_run=true" >> $GITHUB_OUTPUT + echo "PR contains changes outside filter paths — proceeding." + echo "should_sync=true" >> $GITHUB_OUTPUT else - echo "All changes are under .github/workflows/ — skipping workflow." - echo "should_run=false" >> $GITHUB_OUTPUT + echo "All changes are under filter paths — skipping workflow." + echo "should_sync=false" >> $GITHUB_OUTPUT fi check-merge-state: @@ -128,7 +128,7 @@ jobs: dispatch-to-internal: needs: [check-file-changes, check-merge-state] - if: needs.check-merge-state.outputs.checks_passed == 'true' && needs.check-file-changes.outputs.should_run == 'true' && github.event.review.state == 'approved' + 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 From 3084abfc107f52ba51d88e74e4eedb72bf293e5d Mon Sep 17 00:00:00 2001 From: Kitty Chiu <42864823+KittyChiu@users.noreply.github.com> Date: Wed, 6 May 2026 11:56:52 +1000 Subject: [PATCH 4/4] updated messages --- .github/workflows/deploy-merged-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-merged-pr.yml b/.github/workflows/deploy-merged-pr.yml index 69ef39b..f254ee5 100644 --- a/.github/workflows/deploy-merged-pr.yml +++ b/.github/workflows/deploy-merged-pr.yml @@ -36,10 +36,10 @@ jobs: 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 filter paths — proceeding." + echo "PR contains changes outside filtered paths — proceeding." echo "should_sync=true" >> $GITHUB_OUTPUT else - echo "All changes are under filter paths — skipping workflow." + echo "All changes are under filtered paths — skipping workflow." echo "should_sync=false" >> $GITHUB_OUTPUT fi