From 0691ca40cdc01ca871845ea5131b7230e5b4186a Mon Sep 17 00:00:00 2001 From: JakkrapartXD Date: Tue, 10 Feb 2026 13:57:34 +0700 Subject: [PATCH] feat: Implement short SHA for backend image tagging and deployment, and refine image tag resolution for pull requests. --- .forgejo/workflows/deploy-backend.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/deploy-backend.yaml b/.forgejo/workflows/deploy-backend.yaml index 84c6cfe3..bb94a58a 100644 --- a/.forgejo/workflows/deploy-backend.yaml +++ b/.forgejo/workflows/deploy-backend.yaml @@ -16,7 +16,7 @@ env: # Docker Image BACKEND_IMAGE_NAME: chamomind/elearning-backend - IMAGE_TAG: ${{ github.sha }} + IMAGE_TAG: ${{ github.event.pull_request.head.sha || github.sha }} # Notifications DISCORD_WEBHOOK_URL: ${{ vars.DISCORD_WEBHOOK_URL }} @@ -25,10 +25,16 @@ jobs: build: name: Build Backend Docker Image runs-on: ubuntu-latest + outputs: + short_sha: ${{ steps.vars.outputs.short_sha }} steps: - name: Checkout code uses: actions/checkout@v4 + - name: Generate short SHA + id: vars + run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT + - name: Log in to Container Registry uses: docker/login-action@v3 with: @@ -48,7 +54,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:${{ env.IMAGE_TAG }} + images: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }} tags: | type=ref,event=branch type=sha,prefix= @@ -80,7 +86,7 @@ jobs: script: | cd ~/repo chmod +x ./replace-env.sh ./deploy.sh - ./replace-env.sh BACKEND_TAG "${{ env.IMAGE_TAG }}" + ./replace-env.sh BACKEND_TAG "${{ needs.build.outputs.short_sha }}" ./deploy.sh backend notify: