refactor: Standardize container registry configuration, remove insecure Docker flags, and align deployment to the dev branch.

This commit is contained in:
JakkrapartXD 2026-02-10 10:27:13 +07:00
parent f4fa63fd11
commit e8a4e40321
2 changed files with 23 additions and 17 deletions

View file

@ -9,6 +9,11 @@ on:
- 'Frontend-Learner/**' - 'Frontend-Learner/**'
workflow_dispatch: workflow_dispatch:
env:
REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
jobs: jobs:
build: build:
name: Build Frontend Learner Docker Image name: Build Frontend Learner Docker Image
@ -21,27 +26,26 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
config-inline: | config-inline: |
[registry."${{ vars.DOCKER_REGISTRY }}"] [registry."${{ env.REGISTRY }}"]
http = true http = true
insecure = true insecure = true
- name: Login to Docker Registry - name: Login to Docker Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ vars.DOCKER_REGISTRY }} registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ env.REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ env.REGISTRY_PASSWORD }}
insecure: true
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: ${{ vars.DOCKER_REGISTRY }}/elearning-frontend-learner images: ${{ env.REGISTRY }}/elearning-frontend-learner
tags: | tags: |
type=ref,event=branch type=ref,event=branch
type=sha,prefix= type=sha,prefix=
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@ -53,13 +57,12 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
insecure: true
deploy: deploy:
name: Deploy Frontend Learner to Server name: Deploy Frontend Learner to Server
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' if: github.ref == 'refs/heads/dev'
steps: steps:
- name: Remote Deploy - name: Remote Deploy
uses: appleboy/ssh-action@v1.2.1 uses: appleboy/ssh-action@v1.2.1

View file

@ -9,6 +9,11 @@ on:
- 'frontend_management/**' - 'frontend_management/**'
workflow_dispatch: workflow_dispatch:
env:
REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
jobs: jobs:
build: build:
name: Build Frontend Management Docker Image name: Build Frontend Management Docker Image
@ -21,27 +26,26 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
config-inline: | config-inline: |
[registry."${{ vars.DOCKER_REGISTRY }}"] [registry."${{ env.REGISTRY }}"]
http = true http = true
insecure = true insecure = true
- name: Login to Docker Registry - name: Login to Docker Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ vars.DOCKER_REGISTRY }} registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ env.REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ env.REGISTRY_PASSWORD }}
insecure: true
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: ${{ vars.DOCKER_REGISTRY }}/elearning-frontend-management images: ${{ env.REGISTRY }}/elearning-frontend-management
tags: | tags: |
type=ref,event=branch type=ref,event=branch
type=sha,prefix= type=sha,prefix=
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@ -53,7 +57,6 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
insecure: true
deploy: deploy:
name: Deploy Frontend Management to Server name: Deploy Frontend Management to Server