Fix CI matrix and pnpm cache: set env vars in workflow, drop matrix
- Set PNPM_STORE_DIR and COREPACK_HOME as job env vars instead of relying on container.options -e flags which act_runner may ignore - Replace fragile cross-job matrix with single-job loop for builds - Both fixes: empty matrix app name and 0 reused packages
This commit is contained in:
@@ -11,33 +11,11 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
apps: ${{ steps.filter.outputs.apps }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Detect changed apps
|
||||
id: filter
|
||||
run: |
|
||||
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||
CHANGED=$(git diff --name-only origin/main...HEAD)
|
||||
else
|
||||
CHANGED=$(git diff --name-only HEAD~1)
|
||||
fi
|
||||
APPS=""
|
||||
for app in web api harness; do
|
||||
if echo "$CHANGED" | grep -qE "^(apps/${app}/|packages/)"; then
|
||||
APPS="${APPS:+$APPS,}\"${app}\""
|
||||
fi
|
||||
done
|
||||
echo "apps=[${APPS}]" >> "$GITHUB_OUTPUT"
|
||||
|
||||
lint-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PNPM_STORE_DIR: /pnpm-store
|
||||
COREPACK_HOME: /pnpm-store/.corepack
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -48,30 +26,56 @@ jobs:
|
||||
- run: pnpm turbo lint test
|
||||
|
||||
build:
|
||||
needs: [changes, lint-and-test]
|
||||
needs: [lint-and-test]
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.changes.outputs.apps != '[]'
|
||||
strategy:
|
||||
matrix:
|
||||
app: ${{ fromJson(needs.changes.outputs.apps) }}
|
||||
env:
|
||||
PNPM_STORE_DIR: /pnpm-store
|
||||
COREPACK_HOME: /pnpm-store/.corepack
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- run: corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
- run: pnpm turbo build --filter=@homelab/${{ matrix.app }}
|
||||
|
||||
- name: Build Docker image
|
||||
- name: Detect and build changed apps
|
||||
run: |
|
||||
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||
CHANGED=$(git diff --name-only origin/main...HEAD)
|
||||
else
|
||||
CHANGED=$(git diff --name-only HEAD~1)
|
||||
fi
|
||||
for app in web api harness; do
|
||||
if echo "$CHANGED" | grep -qE "^(apps/${app}/|packages/)"; then
|
||||
echo "Building $app..."
|
||||
pnpm turbo build --filter=@homelab/${app}
|
||||
docker build \
|
||||
-t gitea.coreworlds.io/lazorgurl/homelab-${{ matrix.app }}:${{ gitea.sha }} \
|
||||
-t gitea.coreworlds.io/lazorgurl/homelab-${{ matrix.app }}:pr-${{ gitea.event.number }} \
|
||||
apps/${{ matrix.app }}
|
||||
-t gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }} \
|
||||
apps/${app}
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Push to registry
|
||||
if: gitea.event_name == 'push' || gitea.event_name == 'pull_request'
|
||||
- name: Push images
|
||||
run: |
|
||||
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||
CHANGED=$(git diff --name-only origin/main...HEAD)
|
||||
else
|
||||
CHANGED=$(git diff --name-only HEAD~1)
|
||||
fi
|
||||
HAS_IMAGES=false
|
||||
for app in web api harness; do
|
||||
if echo "$CHANGED" | grep -qE "^(apps/${app}/|packages/)"; then
|
||||
HAS_IMAGES=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$HAS_IMAGES" = "true" ]; then
|
||||
echo "${{ gitea.token }}" | docker login gitea.coreworlds.io -u ${{ gitea.actor }} --password-stdin
|
||||
docker push gitea.coreworlds.io/lazorgurl/homelab-${{ matrix.app }}:${{ gitea.sha }}
|
||||
for app in web api harness; do
|
||||
if echo "$CHANGED" | grep -qE "^(apps/${app}/|packages/)"; then
|
||||
docker push gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -7,6 +7,9 @@ on:
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PNPM_STORE_DIR: /pnpm-store
|
||||
COREPACK_HOME: /pnpm-store/.corepack
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ on:
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PNPM_STORE_DIR: /pnpm-store
|
||||
COREPACK_HOME: /pnpm-store/.corepack
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
||||
Reference in New Issue
Block a user