name: Build and Update Flux on: push: branches: - main paths-ignore: # CRITICAL: Do not trigger this action if we are just updating the Helm chart, # otherwise it will create an infinite loop! - "helm/**" env: REGISTRY: git.h0melab.uk IMAGE_NAME: git.h0melab.uk/rgcosta/slashroot-cc # Change this to your actual Gitea username / infra repo name INFRA_REPO: h0melab/infra-cluster-fluxcd jobs: build-push-update: runs-on: docker steps: - name: Checkout Code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Log in to Gitea Container Registry uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Build and Push Docker Image uses: docker/build-push-action@v4 with: context: . push: true tags: | ${{ env.IMAGE_NAME }}:${{ gitea.sha }} ${{ env.IMAGE_NAME }}:latest - name: Checkout Infra Repository uses: actions/checkout@v3 with: repository: ${{ env.INFRA_REPO }} token: ${{ secrets.INFRA_REPO_TOKEN }} path: infra-workspace - name: Update Helm values.yaml for Flux run: | # Go into the downloaded infrastructure repo cd infra-workspace # 1. Update the image tag in your local Helm chart using sed sed -i "s/tag: .*/tag: ${{ gitea.sha }}/g" charts/slashroot/values.yaml # 2. Configure the Gitea Bot to commit the change git config user.name "Gitea Actions Bot" git config user.email "actions@gitea.local" # Commit and Push back to the Infra Repo git add . git commit -m "BOT: (bump) slashroot-cc update: ${{ gitea.sha }}" # Push the changes (The token we provided earlier handles authentication) git push origin main