feat: Implement short SHA for backend image tagging and deployment, and refine image tag resolution for pull requests.
All checks were successful
Build and Deploy Backend / Build Backend Docker Image (push) Successful in 20s
Build and Deploy Backend / Deploy E-learning Backend to Dev Server (push) Successful in 3s
Build and Deploy Backend / Notify Deployment Status (push) Successful in 2s

This commit is contained in:
JakkrapartXD 2026-02-10 13:57:34 +07:00
parent 3322801803
commit 0691ca40cd

View file

@ -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: