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
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
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:
|
lint-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
PNPM_STORE_DIR: /pnpm-store
|
||||||
|
COREPACK_HOME: /pnpm-store/.corepack
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -48,30 +26,56 @@ jobs:
|
|||||||
- run: pnpm turbo lint test
|
- run: pnpm turbo lint test
|
||||||
|
|
||||||
build:
|
build:
|
||||||
needs: [changes, lint-and-test]
|
needs: [lint-and-test]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: needs.changes.outputs.apps != '[]'
|
env:
|
||||||
strategy:
|
PNPM_STORE_DIR: /pnpm-store
|
||||||
matrix:
|
COREPACK_HOME: /pnpm-store/.corepack
|
||||||
app: ${{ fromJson(needs.changes.outputs.apps) }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- run: corepack enable && corepack prepare pnpm@latest --activate
|
- run: corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
- run: pnpm install --frozen-lockfile
|
- run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- run: pnpm turbo build --filter=@homelab/${{ matrix.app }}
|
- name: Detect and build changed apps
|
||||||
|
|
||||||
- name: Build Docker image
|
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||||
-t gitea.coreworlds.io/lazorgurl/homelab-${{ matrix.app }}:${{ gitea.sha }} \
|
CHANGED=$(git diff --name-only origin/main...HEAD)
|
||||||
-t gitea.coreworlds.io/lazorgurl/homelab-${{ matrix.app }}:pr-${{ gitea.event.number }} \
|
else
|
||||||
apps/${{ matrix.app }}
|
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-${app}:${{ gitea.sha }} \
|
||||||
|
apps/${app}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
- name: Push to registry
|
- name: Push images
|
||||||
if: gitea.event_name == 'push' || gitea.event_name == 'pull_request'
|
|
||||||
run: |
|
run: |
|
||||||
echo "${{ gitea.token }}" | docker login gitea.coreworlds.io -u ${{ gitea.actor }} --password-stdin
|
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||||
docker push gitea.coreworlds.io/lazorgurl/homelab-${{ matrix.app }}:${{ gitea.sha }}
|
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
|
||||||
|
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:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
PNPM_STORE_DIR: /pnpm-store
|
||||||
|
COREPACK_HOME: /pnpm-store/.corepack
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
PNPM_STORE_DIR: /pnpm-store
|
||||||
|
COREPACK_HOME: /pnpm-store/.corepack
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
Reference in New Issue
Block a user