Skip to content

Commit 2b984b9

Browse files
committed
update discover
1 parent 931e0e2 commit 2b984b9

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

.github/workflows/experiment.yaml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,24 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
jobs:
13-
# 2. DISCOVERY: Find exactly what changed and output JSON
1413
discover:
1514
runs-on: ubuntu-latest
1615
outputs:
17-
packages: ${{ steps.set-matrix.outputs.packages }}
16+
packages: ${{ steps.changes.outputs.all_changed_files }}
1817
steps:
1918
- uses: actions/checkout@v4
2019
with:
21-
fetch-depth: 0 # Needed to diff against main
22-
23-
- name: Calculate Changed Packages
24-
id: set-matrix
25-
run: |
26-
# Find all modified directories inside packages/
27-
CHANGED=$(git diff --name-only origin/main...HEAD | grep "^packages/" | cut -d/ -f2 | sort -u || true)
20+
fetch-depth: 0
2821

29-
if [ -z "$CHANGED" ]; then
30-
echo "packages=[]" >> $GITHUB_OUTPUT
31-
exit 0
32-
fi
33-
34-
# Convert bash list to JSON array using jq
35-
JSON_ARRAY=$(jq -R -s -c 'split("\n")[:-1]' <<< "$CHANGED")
36-
echo "Discovered packages: $JSON_ARRAY"
37-
echo "packages=$JSON_ARRAY" >> $GITHUB_OUTPUT
22+
- name: Detect Changed Packages
23+
id: changes
24+
uses: tj-actions/changed-files@v44
25+
with:
26+
files: packages/** # Only watch the packages directory
27+
dir_names: true # Return folder names, not files
28+
dir_names_max_depth: 2 # Strip it down to just "google-cloud-storage"
29+
json: true # Output a perfect JSON array for the matrix
30+
escape_json: false
3831

3932
# 3. EXECUTION: Native Fan-out Matrix
4033
unit-test:

0 commit comments

Comments
 (0)