From f1a4ed1a5b07883fbf116ab145923a6fe369f6f5 Mon Sep 17 00:00:00 2001 From: jmaasy Date: Mon, 22 Dec 2025 22:24:28 +0100 Subject: [PATCH] updated workflow --- .github/workflows/build-deploy.yaml | 53 +++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-deploy.yaml b/.github/workflows/build-deploy.yaml index bb3d7be..85f360e 100644 --- a/.github/workflows/build-deploy.yaml +++ b/.github/workflows/build-deploy.yaml @@ -11,6 +11,7 @@ on: jobs: build: runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'Update image tag to')" steps: - name: Checkout code uses: actions/checkout@v4 @@ -25,30 +26,54 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Login to Gitea Container Registry + continue-on-error: true + uses: docker/login-action@v3 + with: + registry: ${{ secrets.GITEA_REGISTRY_URL }} + username: ${{ secrets.GITEA_USERNAME }} + password: ${{ secrets.GITEA_TOKEN }} + - name: Build Docker image run: | - IMAGE_REPO="ghcr.io/${GITHUB_REPOSITORY,,}" + GITHUB_IMAGE="ghcr.io/${GITHUB_REPOSITORY,,}" + GITEA_IMAGE="${{ secrets.GITEA_REGISTRY_URL }}/${GITHUB_REPOSITORY,,}" docker buildx build \ --platform linux/arm64 \ - -t $IMAGE_REPO:latest \ - -t $IMAGE_REPO:${{ github.sha }} \ + -t $GITHUB_IMAGE:latest \ + -t $GITHUB_IMAGE:${{ github.sha }} \ + -t $GITEA_IMAGE:latest \ + -t $GITEA_IMAGE:${{ github.sha }} \ --load . - - name: Push Docker image + - name: Push Docker image to GitHub run: | - IMAGE_REPO="ghcr.io/${GITHUB_REPOSITORY,,}" - docker push $IMAGE_REPO:latest - docker push $IMAGE_REPO:${{ github.sha }} + GITHUB_IMAGE="ghcr.io/${GITHUB_REPOSITORY,,}" + docker push $GITHUB_IMAGE:latest + docker push $GITHUB_IMAGE:${{ github.sha }} + + - name: Push Docker image to Gitea + continue-on-error: true + run: | + GITEA_IMAGE="${{ secrets.GITEA_REGISTRY_URL }}/${GITHUB_REPOSITORY,,}" + docker push $GITEA_IMAGE:latest + docker push $GITEA_IMAGE:${{ github.sha }} - name: Update image in manifest run: | IMAGE_REPO="ghcr.io/${GITHUB_REPOSITORY,,}" sed -i "s|ghcr.io/.*/httpdoges:.*|$IMAGE_REPO:${{ github.sha }}|g" manifest/k8s.yaml - - name: Commit and push changes - run: | - git config user.name "github-actions" - git config user.email "github-actions@github.com" - git add manifest/k8s.yaml - git commit -m "Update image tag to ${{ github.sha }}" - git push \ No newline at end of file + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: "Update image tag to ${{ github.sha }}" + branch: update-image-${{ github.sha }} + title: "Update Docker image to ${{ github.sha }}" + body: | + This PR updates the Docker image tag in the Kubernetes manifest. + + - Image: ghcr.io/${{ github.repository }}:${{ github.sha }} + - Triggered by: ${{ github.event.head_commit.message }} + committer: github-actions + author: github-actions \ No newline at end of file