act_runner v0.3.0 doesn't propagate workflow-level or job-level env: blocks to job containers. Use export in run commands instead. First run warms cache, subsequent runs will show reused packages.
89 lines
2.6 KiB
YAML
89 lines
2.6 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 pnpm
|
|
run: |
|
|
export COREPACK_HOME=/pnpm-store/.corepack
|
|
corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
export PNPM_STORE_DIR=/pnpm-store
|
|
pnpm install --frozen-lockfile
|
|
|
|
- name: Lint and test
|
|
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 pnpm
|
|
run: |
|
|
export COREPACK_HOME=/pnpm-store/.corepack
|
|
corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
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 "${{ 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
|