feat: Implement short SHA for backend image tagging and deployment, and refine image tag resolution for pull requests.
This commit is contained in:
parent
3322801803
commit
0691ca40cd
1 changed files with 9 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue