diff --git a/.gitea/workflows/deploy-preview.yaml b/.gitea/workflows/deploy-preview.yaml index 9344e54..d2d1ae4 100644 --- a/.gitea/workflows/deploy-preview.yaml +++ b/.gitea/workflows/deploy-preview.yaml @@ -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 diff --git a/.gitea/workflows/deploy-production.yaml b/.gitea/workflows/deploy-production.yaml index 7e11d10..0e2dcec 100644 --- a/.gitea/workflows/deploy-production.yaml +++ b/.gitea/workflows/deploy-production.yaml @@ -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" diff --git a/.github/workflows/deploy-preview.yaml b/.github/workflows/deploy-preview.yaml deleted file mode 100644 index 134eb88..0000000 --- a/.github/workflows/deploy-preview.yaml +++ /dev/null @@ -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}\`.` - }) diff --git a/.github/workflows/deploy-production.yaml b/.github/workflows/deploy-production.yaml deleted file mode 100644 index 2b04ba1..0000000 --- a/.github/workflows/deploy-production.yaml +++ /dev/null @@ -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