Skip to content

Commit d3b1b03

Browse files
committed
fix(ci): improve changed projects detection script in release workflow
- Added debug logs to trace project detection and changed directory checks - Changed environment variable value to use double quotes for consistency - Handled case where no projects with package.json are found - Added conditional to set changed projects to empty if no changes or projects found - Replaced echo -n with printf for base64 encoding compatibility - Trimmed leading and trailing spaces in changed projects clean string - Ensured base64 encoding output has no trailing newlines - Cleaned up output formatting and added detailed logging for easier troubleshooting
1 parent 356427a commit d3b1b03

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
contents: write
1313
packages: write
1414
env:
15-
MY_DASHBOARD_DATABASE_POSTGRES_URL: postgres://postgres:pgtoolspassword@localhost:5432/postgres?schema=public
15+
MY_DASHBOARD_DATABASE_POSTGRES_URL: "postgres://postgres:pgtoolspassword@localhost:5432/postgres?schema=public"
1616

1717
steps:
1818
- name: Checkout repository
@@ -41,22 +41,46 @@ jobs:
4141
- name: Detect changed projects
4242
id: detect
4343
run: |
44+
echo "Starting project detection..."
45+
4446
PROJECTS=$(find . -maxdepth 1 -type d ! -path "." ! -path "./.github*" ! -path "./.vscode*" ! -path "./scripts*" ! -path "./demo*" | while read d; do
4547
if [ -f "$d/package.json" ]; then echo "$(basename "$d")"; fi
4648
done)
4749
50+
echo "Found projects: '$PROJECTS'"
51+
52+
# Handle case where no projects are found
53+
if [ -z "$PROJECTS" ]; then
54+
echo "No projects found with package.json files"
55+
PROJECTS=""
56+
fi
57+
4858
if [ "${{ steps.need_ci.outputs.force_run }}" = "true" ]; then
4959
CHANGED_PROJECTS="$PROJECTS"
60+
echo "Force run enabled, using all projects"
5061
else
62+
echo "Checking for changed files..."
5163
CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | cut -d/ -f1 | sort | uniq | grep -v -E '^(.github|.vscode|scripts|demo)$')
52-
CHANGED_PROJECTS=$(echo "$PROJECTS" | grep -Fxf <(echo "$CHANGED") || true)
64+
echo "Changed directories: '$CHANGED'"
65+
66+
if [ -n "$CHANGED" ] && [ -n "$PROJECTS" ]; then
67+
echo "Filtering projects based on changes..."
68+
CHANGED_PROJECTS=$(echo "$PROJECTS" | grep -Fxf <(echo "$CHANGED") || true)
69+
else
70+
echo "No changes or no projects found, setting empty"
71+
CHANGED_PROJECTS=""
72+
fi
5373
fi
5474
5575
echo "Changed projects: $CHANGED_PROJECTS"
5676
57-
CHANGED_PROJECTS_CLEAN=$(echo "$CHANGED_PROJECTS" | tr '\n' ' ' | sed 's/ $//')
58-
ENCODED=$(echo -n "$CHANGED_PROJECTS_CLEAN" | base64)
77+
CHANGED_PROJECTS_CLEAN=$(echo "$CHANGED_PROJECTS" | tr '\n' ' ' | sed 's/ $//' | sed 's/^[[:space:]]*//')
78+
echo "Changed projects clean: '$CHANGED_PROJECTS_CLEAN'"
79+
80+
# Use printf instead of echo -n for better compatibility
81+
ENCODED=$(printf "%s" "$CHANGED_PROJECTS_CLEAN" | base64 | tr -d '\n')
5982
echo "changed_projects_base64=$ENCODED" >> $GITHUB_OUTPUT
83+
echo "Encoded value: $ENCODED"
6084
6185
# 🧩 Определяем тип bump'а
6286
- name: Determine bump type

0 commit comments

Comments
 (0)