82 lines
2.4 KiB
YAML
82 lines
2.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main]
|
|
|
|
concurrency:
|
|
group: ${{ gitea.workflow }}-${{ gitea.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lint-and-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup and install
|
|
run: |
|
|
export COREPACK_HOME=/pnpm-store/.corepack
|
|
corepack enable && corepack prepare pnpm@latest --activate
|
|
export PNPM_STORE_DIR=/pnpm-store
|
|
pnpm install --frozen-lockfile
|
|
|
|
- run: pnpm turbo lint test
|
|
|
|
build:
|
|
needs: [lint-and-test]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup and install
|
|
run: |
|
|
export COREPACK_HOME=/pnpm-store/.corepack
|
|
corepack enable && corepack prepare pnpm@latest --activate
|
|
export PNPM_STORE_DIR=/pnpm-store
|
|
pnpm install --frozen-lockfile
|
|
|
|
- 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-${app}:${{ gitea.sha }} \
|
|
apps/${app}
|
|
fi
|
|
done
|
|
|
|
- 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 "${{ secrets.REGISTRY_TOKEN }}" | docker login gitea.coreworlds.io -u lazorgurl --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
|