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: