62 lines
2.3 KiB
YAML
62 lines
2.3 KiB
YAML
name: Deploy Production
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
- name: Install tools
|
|
run: |
|
|
apt-get update && apt-get install -y jq curl
|
|
curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.6.0/kustomize_v5.6.0_linux_amd64.tar.gz | tar xz -C /usr/local/bin
|
|
|
|
- run: corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
- run: pnpm install --frozen-lockfile
|
|
|
|
- name: Determine changed apps
|
|
id: changes
|
|
run: |
|
|
APPS=$(pnpm turbo build --filter='...[HEAD~1]' --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 }} \
|
|
-t gitea.coreworlds.io/lazorgurl/homelab-${app}:latest \
|
|
apps/${app}
|
|
docker push gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }}
|
|
docker push gitea.coreworlds.io/lazorgurl/homelab-${app}:latest
|
|
done
|
|
|
|
- name: Update image tags in production 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/production
|
|
kustomize edit set image gitea.coreworlds.io/lazorgurl/homelab-${app}=gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }}
|
|
cd -
|
|
done
|
|
|
|
- name: Commit image tag updates
|
|
if: steps.changes.outputs.apps != ''
|
|
run: |
|
|
git config user.name "gitea-actions[bot]"
|
|
git config user.email "gitea-actions[bot]@coreworlds.io"
|
|
git add apps/*/k8s/overlays/production/
|
|
git diff --staged --quiet || git commit -m "deploy: update production images to ${{ gitea.sha }}"
|
|
git push
|