From bc7d269cc44b538160976f719588faf8fd7c5b1b Mon Sep 17 00:00:00 2001 From: Roger Oriol Date: Sat, 24 Jan 2026 18:15:40 +0100 Subject: [PATCH] add gitea workflows --- .gitea/workflows/build-and-deploy.yaml | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .gitea/workflows/build-and-deploy.yaml diff --git a/.gitea/workflows/build-and-deploy.yaml b/.gitea/workflows/build-and-deploy.yaml new file mode 100644 index 0000000..73af7d7 --- /dev/null +++ b/.gitea/workflows/build-and-deploy.yaml @@ -0,0 +1,67 @@ +name: Build and Deploy + +on: + push: + branches: + - main + - master + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: gitea.yourdomain.com # Replace with your Gitea domain + username: ${{ gitea.actor }} + password: ${{ secrets.GITEA_TOKEN }} + + - name: Extract version from commit + id: version + run: | + # Use short commit SHA as version tag + VERSION=$(git rev-parse --short HEAD) + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "Building version: ${VERSION}" + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + gitea.yourdomain.com/${{ gitea.repository_owner }}/gym-tracker:${{ steps.version.outputs.version }} + gitea.yourdomain.com/${{ gitea.repository_owner }}/gym-tracker:latest + cache-from: type=registry,ref=gitea.yourdomain.com/${{ gitea.repository_owner }}/gym-tracker:latest + cache-to: type=inline + + - name: Checkout k3s-cluster repo + uses: actions/checkout@v4 + with: + repository: yourusername/k3s-cluster # Replace with your manifests repo + token: ${{ secrets.K3S_REPO_TOKEN }} + path: k3s-cluster + + - name: Update deployment image tag + run: | + cd k3s-cluster + # Update the image tag in the deployment file + sed -i "s|image: gitea.yourdomain.com/.*/gym-tracker:.*|image: gitea.yourdomain.com/${{ gitea.repository_owner }}/gym-tracker:${{ steps.version.outputs.version }}|g" gym-tracker/deployment.yaml + + - name: Commit and push changes + run: | + cd k3s-cluster + git config user.name "Gitea Actions" + git config user.email "actions@gitea.local" + git add gym-tracker/deployment.yaml + git diff --staged --quiet || git commit -m "Update gym-tracker image to ${{ steps.version.outputs.version }}" + git push