Fix deploy: use if/then instead of && to avoid pipefail exit
The Dockerfile check in the while-read loop used `[ -f ... ] && echo`, which exits non-zero for packages without Dockerfiles. With bash's pipefail, this killed the entire step. Also remove unused GitHub workflow copies since CI runs on Gitea only.
This commit is contained in:
@@ -20,7 +20,7 @@ jobs:
|
||||
- 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(",")' | tr ',' '\n' | while read app; do [ -f "apps/${app}/Dockerfile" ] && echo "$app"; done | paste -sd, -)
|
||||
APPS=$(pnpm turbo build --filter='...[origin/main]' --dry-run=json | jq -r '[.packages[] | select(startswith("@homelab/")) | sub("@homelab/";"") ] | join(",")' | tr ',' '\n' | while read app; do if [ -f "apps/${app}/Dockerfile" ]; then echo "$app"; fi; done | paste -sd, -)
|
||||
echo "apps=$APPS" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build and push images
|
||||
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
APPS="$INPUT"
|
||||
fi
|
||||
else
|
||||
APPS=$(pnpm turbo build --filter='...[HEAD~1]' --dry-run=json | jq -r '[.packages[] | select(startswith("@homelab/")) | sub("@homelab/";"") ] | join(",")' | tr ',' '\n' | while read app; do [ -f "apps/${app}/Dockerfile" ] && echo "$app"; done | paste -sd, -)
|
||||
APPS=$(pnpm turbo build --filter='...[HEAD~1]' --dry-run=json | jq -r '[.packages[] | select(startswith("@homelab/")) | sub("@homelab/";"") ] | join(",")' | tr ',' '\n' | while read app; do if [ -f "apps/${app}/Dockerfile" ]; then echo "$app"; fi; done | paste -sd, -)
|
||||
fi
|
||||
echo "apps=$APPS" >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
59
.github/workflows/deploy-preview.yaml
vendored
59
.github/workflows/deploy-preview.yaml
vendored
@@ -1,59 +0,0 @@
|
||||
name: Deploy Preview
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: pnpm
|
||||
|
||||
- run: 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 "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
IFS=',' read -ra APPS <<< "${{ steps.changes.outputs.apps }}"
|
||||
for app in "${APPS[@]}"; do
|
||||
docker build \
|
||||
-t ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.sha }} \
|
||||
apps/${app}
|
||||
docker push ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.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 ghcr.io/${{ github.repository_owner }}/homelab-${app}=ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.sha }}
|
||||
cd -
|
||||
done
|
||||
|
||||
- name: Comment preview URL
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: `## Preview Deploy\nNamespace: \`preview-${context.issue.number}\`\nArgoCD will sync automatically from branch \`${context.payload.pull_request.head.ref}\`.`
|
||||
})
|
||||
68
.github/workflows/deploy-production.yaml
vendored
68
.github/workflows/deploy-production.yaml
vendored
@@ -1,68 +0,0 @@
|
||||
name: Deploy Production
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: pnpm
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Determine changed apps
|
||||
id: changes
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||
APPS="web,api"
|
||||
else
|
||||
APPS=$(pnpm turbo build --filter='...[HEAD~1]' --dry-run=json | jq -r '[.packages[] | select(startswith("@homelab/")) | sub("@homelab/";"") ] | join(",")')
|
||||
fi
|
||||
echo "apps=$APPS" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build and push images
|
||||
if: steps.changes.outputs.apps != ''
|
||||
run: |
|
||||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
IFS=',' read -ra APPS <<< "${{ steps.changes.outputs.apps }}"
|
||||
for app in "${APPS[@]}"; do
|
||||
docker build \
|
||||
-t ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.sha }} \
|
||||
-t ghcr.io/${{ github.repository_owner }}/homelab-${app}:latest \
|
||||
apps/${app}
|
||||
docker push ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.sha }}
|
||||
docker push ghcr.io/${{ github.repository_owner }}/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 ghcr.io/${{ github.repository_owner }}/homelab-${app}=ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.sha }}
|
||||
cd -
|
||||
done
|
||||
|
||||
- name: Commit image tag updates
|
||||
if: steps.changes.outputs.apps != ''
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add apps/*/k8s/overlays/production/
|
||||
git diff --staged --quiet || git commit -m "deploy: update production images to ${{ github.sha }}"
|
||||
git push
|
||||
Reference in New Issue
Block a user