chore: improve ci
Build & Push Docker Image (Backend) / build (push) Successful in 2m5s

This commit is contained in:
Flook
2026-04-28 20:45:14 +07:00
parent 1fe438dea0
commit 1ec6fa68a1
+48 -45
View File
@@ -1,45 +1,48 @@
name: Build & Push Docker Image (Backend) name: Build & Push Docker Image (Backend)
on: on:
push: push:
branches: branches:
- main - main
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout source # Checkout แบบไม่พึ่ง GitHub
uses: actions/checkout@v4 - name: Checkout source (manual)
run: |
- name: Set up Docker Buildx set -e
uses: docker/setup-buildx-action@v3 git clone https://gitea.panmodel.com/admin/lms-backend.git .
git checkout ${{ gitea.sha }}
- name: Login to Docker Hub
uses: docker/login-action@v3 # Login Docker Hub แบบตรง
with: - name: Login to Docker Hub
username: ${{ secrets.DOCKERHUB_USERNAME }} run: |
password: ${{ secrets.DOCKERHUB_TOKEN }} set -e
echo "${{ secrets.DOCKERHUB_TOKEN }}" \
- name: Build and push Docker image | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
uses: docker/build-push-action@v5
with: # Build & Push image แบบตรง
context: . - name: Build and push Docker image
push: true run: |
tags: | set -e
satitprompunjai/lms-backend:${{ gitea.sha }} docker build -t satitprompunjai/lms-backend:${{ gitea.sha }} .
docker push satitprompunjai/lms-backend:${{ gitea.sha }}
- name: Update image tag in lms-k8s
env: # Update GitOps repo
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} - name: Update image tag in lms-k8s
run: | env:
git clone https://admin:${GIT_TOKEN}@gitea.panmodel.com/admin/lms-k8s.git GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
cd lms-k8s run: |
set -e
sed -i "s|satitprompunjai/lms-backend:.*|satitprompunjai/lms-backend:${{ gitea.sha }}|g" apps/backend/deployment.yaml git clone https://admin:${GIT_TOKEN}@gitea.panmodel.com/admin/lms-k8s.git
cd lms-k8s
git config user.name "lms-backend-ci"
git config user.email "ci@panmodel.com" sed -i "s|satitprompunjai/lms-backend:.*|satitprompunjai/lms-backend:${{ gitea.sha }}|g" apps/backend/deployment.yaml
git commit -am "chore: update lms-backend image to ${{ gitea.sha }}"
git push git config user.name "lms-backend-ci"
git config user.email "ci@panmodel.com"
git diff --quiet || git commit -am "chore: update lms-backend image to ${{ gitea.sha }}"
git push