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.
58 lines
2.2 KiB
YAML
58 lines
2.2 KiB
YAML
name: Deploy Preview
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
|
|
jobs:
|
|
deploy:
|
|
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: Determine changed apps
|
|
id: changes
|
|
run: |
|
|
APPS=$(pnpm turbo build --filter='...[origin/main]' --dry-run=json | jq -r '[.packages[] | select(startswith("@homelab/")) | sub("@homelab/";"") ] | join(",")')
|
|
echo "apps=$APPS" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build and push images
|
|
if: steps.changes.outputs.apps != ''
|
|
run: |
|
|
echo "${{ gitea.token }}" | docker login gitea.coreworlds.io -u ${{ gitea.actor }} --password-stdin
|
|
IFS=',' read -ra APPS <<< "${{ steps.changes.outputs.apps }}"
|
|
for app in "${APPS[@]}"; do
|
|
docker build \
|
|
-t gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }} \
|
|
apps/${app}
|
|
docker push gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }}
|
|
done
|
|
|
|
- name: Update image tags in preview overlay
|
|
if: steps.changes.outputs.apps != ''
|
|
run: |
|
|
IFS=',' read -ra APPS <<< "${{ steps.changes.outputs.apps }}"
|
|
for app in "${APPS[@]}"; do
|
|
cd apps/${app}/k8s/overlays/preview
|
|
kustomize edit set image gitea.coreworlds.io/lazorgurl/homelab-${app}=gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }}
|
|
cd -
|
|
done
|
|
|
|
- name: Comment preview URL
|
|
run: |
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${{ gitea.token }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"body\": \"## Preview Deploy\nNamespace: \`preview-${{ gitea.event.number }}\`\nArgoCD will sync automatically.\"}" \
|
|
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/issues/${{ gitea.event.number }}/comments"
|