name: Build and Deploy Resume on: push: branches: [main] paths: - 'index.html' - 'Dockerfile' - 'helm/**' - '.github/workflows/**' pull_request: branches: [main] env: REGISTRY: images.caffeinetux.com IMAGE_NAME: production/resume-site jobs: build: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Harbor Registry if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.HARBOR_USERNAME }} password: ${{ secrets.HARBOR_PASSWORD }} - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch type=sha,prefix= type=raw,value=latest,enable={{is_default_branch}} - name: Build and push uses: docker/build-push-action@v5 with: context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max helm-lint: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Helm uses: azure/setup-helm@v3 with: version: v3.13.0 - name: Lint Helm chart run: helm lint ./helm - name: Template Helm chart run: | helm template resume ./helm \ --set image.repository=test \ --set ingress.hosts[0].host=test.example.com \ --set ingress.hosts[0].paths[0].path=/ \ --set ingress.hosts[0].paths[0].pathType=Prefix # Optional: Deploy to cluster (uncomment and configure) # deploy: # needs: [build, helm-lint] # if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' # runs-on: ubuntu-latest # steps: # - name: Checkout # uses: actions/checkout@v4 # # - name: Set up Helm # uses: azure/setup-helm@v3 # # - name: Configure kubectl # uses: azure/k8s-set-context@v3 # with: # kubeconfig: ${{ secrets.KUBECONFIG }} # # - name: Deploy to Kubernetes # run: | # helm upgrade --install resume ./helm \ # --namespace resume \ # --create-namespace \ # --set image.repository=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} \ # --set image.tag=${{ github.sha }} \ # --wait