diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 4605477..c699158 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -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: | - 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 }} + 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-${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: | - echo "${{ gitea.token }}" | docker login gitea.coreworlds.io -u ${{ gitea.actor }} --password-stdin - docker push gitea.coreworlds.io/lazorgurl/homelab-${{ matrix.app }}:${{ gitea.sha }} + 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 + 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 diff --git a/.gitea/workflows/deploy-preview.yaml b/.gitea/workflows/deploy-preview.yaml index 9562c34..3347fe8 100644 --- a/.gitea/workflows/deploy-preview.yaml +++ b/.gitea/workflows/deploy-preview.yaml @@ -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 diff --git a/.gitea/workflows/deploy-production.yaml b/.gitea/workflows/deploy-production.yaml index d4af090..6d9bbef 100644 --- a/.gitea/workflows/deploy-production.yaml +++ b/.gitea/workflows/deploy-production.yaml @@ -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: