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
|
# Docker Image
|
||||||
BACKEND_IMAGE_NAME: chamomind/elearning-backend
|
BACKEND_IMAGE_NAME: chamomind/elearning-backend
|
||||||
IMAGE_TAG: ${{ github.sha }}
|
IMAGE_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||||
|
|
||||||
# Notifications
|
# Notifications
|
||||||
DISCORD_WEBHOOK_URL: ${{ vars.DISCORD_WEBHOOK_URL }}
|
DISCORD_WEBHOOK_URL: ${{ vars.DISCORD_WEBHOOK_URL }}
|
||||||
|
|
@ -25,10 +25,16 @@ jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Backend Docker Image
|
name: Build Backend Docker Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
short_sha: ${{ steps.vars.outputs.short_sha }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Log in to Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
|
@ -48,7 +54,7 @@ jobs:
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:${{ env.IMAGE_TAG }}
|
images: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=sha,prefix=
|
type=sha,prefix=
|
||||||
|
|
@ -80,7 +86,7 @@ jobs:
|
||||||
script: |
|
script: |
|
||||||
cd ~/repo
|
cd ~/repo
|
||||||
chmod +x ./replace-env.sh ./deploy.sh
|
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
|
./deploy.sh backend
|
||||||
|
|
||||||
notify:
|
notify:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue