From 4e64c83c4b9a8f9b8e26f4ba40661d05c9b07d23 Mon Sep 17 00:00:00 2001 From: Francwa Date: Mon, 22 Dec 2025 08:45:31 +0100 Subject: [PATCH] fix: updated build and push CI/CD configuration --- .gitea/workflows/ci.yml | 48 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index f5793f6..0bcfbf0 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -30,34 +30,42 @@ jobs: name: Build & Push to Registry runs-on: ubuntu-latest needs: test - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Debug ref - run: | - echo "github.ref = ${{ github.ref }}" - echo "GITHUB_REF = $GITHUB_REF" - echo "This should only run on tags!" + steps: - name: Checkout code uses: actions/checkout@v4 - name: Load config from Makefile id: config run: | - eval "$(make _ci-image-name)" + eval "$(make -s _ci-image-name)" echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT - - name: Extract version from tag - id: version - run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + - name: 🏷️ Docker Metadata (Tags & Labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: gitea.iswearihadsomethingforthis.net/francwa/${{ steps.config.outputs.image_name }} + tags: | + # Case 1 - Git Tag (v1.2.3) + type=semver,pattern={{version}} + # Case 2 - Push on main + type=raw,value=latest,enable={{is_default_branch}} + # Both case - Commit sha + type=sha - - name: Build production image - run: make build + - name: Login to Gitea Registry + uses: docker/login-action@v3 + with: + registry: gitea.iswearihadsomethingforthis.net + username: ${{ gitea.actor }} + password: ${{ secrets.G1T34_TOKEN }} - - name: Tag and push to registry - run: | - docker tag ${{ steps.config.outputs.image_name }}:latest ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ steps.config.outputs.image_name }}:${{ steps.version.outputs.version }} - docker tag ${{ steps.config.outputs.image_name }}:latest ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ steps.config.outputs.image_name }}:latest - echo "${{ secrets.G1T34_TOKEN }}" | docker login ${{ env.REGISTRY_URL }} -u ${{ env.REGISTRY_USER }} --password-stdin - docker push ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ steps.config.outputs.image_name }}:${{ steps.version.outputs.version }} - docker push ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ steps.config.outputs.image_name }}:latest + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./brain/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}