This commit is contained in:
2025-02-27 17:39:39 +01:00
parent 2f0782e079
commit f85e4a5c1f

View File

@@ -26,32 +26,51 @@ jobs:
- name: Check for changed files - name: Check for changed files
id: filter id: filter
shell: bash # Explicitly specify bash
run: | run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "Checking for changes..."
# If manually triggered, build both
echo "backend=true" >> $GITHUB_OUTPUT
echo "frontend=true" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" = refs/tags/* ]; then
# If it's a tag, build both
echo "backend=true" >> $GITHUB_OUTPUT
echo "frontend=true" >> $GITHUB_OUTPUT
else
# Check which directories have changes
git fetch origin main
if git diff --name-only origin/main..HEAD | grep -q "^backend/"; then # Initialize outputs
echo "backend=true" >> $GITHUB_OUTPUT BACKEND="false"
else FRONTEND="false"
echo "backend=false" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "Workflow manually triggered - building both"
BACKEND="true"
FRONTEND="true"
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "Tag detected - building both"
BACKEND="true"
FRONTEND="true"
else
echo "Checking changed files between main and current commit..."
# Get the base ref for the comparison
BASE_SHA=$(git rev-parse origin/main)
CURRENT_SHA=${{ github.sha }}
echo "Comparing $BASE_SHA...$CURRENT_SHA"
# Check backend changes
if git diff --name-only $BASE_SHA $CURRENT_SHA | grep -q "^backend/"; then
echo "Backend changes detected"
BACKEND="true"
fi fi
if git diff --name-only origin/main..HEAD | grep -q "^frontend/"; then # Check frontend changes
echo "frontend=true" >> $GITHUB_OUTPUT if git diff --name-only $BASE_SHA $CURRENT_SHA | grep -q "^frontend/"; then
else echo "Frontend changes detected"
echo "frontend=false" >> $GITHUB_OUTPUT FRONTEND="true"
fi fi
fi fi
# Output results
echo "backend=$BACKEND" >> $GITHUB_OUTPUT
echo "frontend=$FRONTEND" >> $GITHUB_OUTPUT
# Debug output
echo "Debug: Backend will build: $BACKEND"
echo "Debug: Frontend will build: $FRONTEND"
build-backend: build-backend:
needs: changes needs: changes
@@ -60,7 +79,6 @@ jobs:
container: container:
image: ghcr.io/catthehacker/ubuntu:act-latest image: ghcr.io/catthehacker/ubuntu:act-latest
steps: steps:
# Rest of your backend job...
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4