Deploy Prod #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Prod | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| env: | |
| HARBOR_REGISTRY: harbor.homelab.robinjoon.xyz | |
| IMAGE_NAME: loop/frontend | |
| jobs: | |
| test: | |
| runs-on: [self-hosted, macOS, ARM64] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.14.2 | |
| - name: Set up Node.js 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run type checks | |
| run: pnpm run typecheck | |
| build-and-push: | |
| runs-on: [self-hosted, macOS, ARM64] | |
| needs: test | |
| outputs: | |
| image-tag: ${{ steps.meta.outputs.tag }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Generate image tag | |
| id: meta | |
| run: | | |
| TAG=$(date +'%Y%m%d')-${{ github.run_number }} | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Harbor | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.HARBOR_REGISTRY }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ env.HARBOR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tag }} | |
| ${{ env.HARBOR_REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| build-args: | | |
| VITE_GRAPHQL_ENDPOINT=${{ secrets.VITE_GRAPHQL_ENDPOINT }} | |
| update-helm: | |
| runs-on: [self-hosted, macOS, ARM64] | |
| needs: build-and-push | |
| steps: | |
| - name: Checkout Helm repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Spotit-KR/loop-helm | |
| token: ${{ secrets.HELM_REPO_PAT }} | |
| path: helm-repo | |
| - name: Update image tag in values-prod.yaml | |
| run: | | |
| cd helm-repo | |
| sed -i '' 's/tag: ".*"/tag: "${{ needs.build-and-push.outputs.image-tag }}"/' frontend/values/values-prod.yaml | |
| - name: Commit and push changes | |
| run: | | |
| cd helm-repo | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add frontend/values/values-prod.yaml | |
| git commit -m "chore: update frontend prod image tag to ${{ needs.build-and-push.outputs.image-tag }}" | |
| git push |