This commit is contained in:
@@ -10,36 +10,39 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
# Checkout แบบไม่พึ่ง GitHub
|
||||
- name: Checkout source (manual)
|
||||
run: |
|
||||
set -e
|
||||
git clone https://gitea.panmodel.com/admin/lms-backend.git .
|
||||
git checkout ${{ gitea.sha }}
|
||||
|
||||
# Login Docker Hub แบบตรง
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
run: |
|
||||
set -e
|
||||
echo "${{ secrets.DOCKERHUB_TOKEN }}" \
|
||||
| docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
||||
|
||||
# Build & Push image แบบตรง
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
satitprompunjai/lms-backend:${{ gitea.sha }}
|
||||
run: |
|
||||
set -e
|
||||
docker build -t satitprompunjai/lms-backend:${{ gitea.sha }} .
|
||||
docker push satitprompunjai/lms-backend:${{ gitea.sha }}
|
||||
|
||||
# Update GitOps repo
|
||||
- name: Update image tag in lms-k8s
|
||||
env:
|
||||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|
||||
run: |
|
||||
git clone https://admin:${GIT_TOKEN}@gitea.panmodel.com/admin/lms-k8s.git
|
||||
cd lms-k8s
|
||||
set -e
|
||||
git clone https://admin:${GIT_TOKEN}@gitea.panmodel.com/admin/lms-k8s.git
|
||||
cd lms-k8s
|
||||
|
||||
sed -i "s|satitprompunjai/lms-backend:.*|satitprompunjai/lms-backend:${{ gitea.sha }}|g" apps/backend/deployment.yaml
|
||||
sed -i "s|satitprompunjai/lms-backend:.*|satitprompunjai/lms-backend:${{ gitea.sha }}|g" apps/backend/deployment.yaml
|
||||
|
||||
git config user.name "lms-backend-ci"
|
||||
git config user.email "ci@panmodel.com"
|
||||
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
|
||||
Reference in New Issue
Block a user