build: update cicd
This commit is contained in:
@@ -10,10 +10,11 @@ on:
|
||||
|
||||
env:
|
||||
REGISTRY: ${{ secrets.REGISTRY_URL }}
|
||||
NAMESPACE: ${{ secrets.REGISTRY_NAMESPACE || 'notytex' }}
|
||||
NAMESPACE: ${{ secrets.REGISTRY_NAMESPACE || 'lafrite' }}
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
build-backend:
|
||||
name: Build Backend Image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -29,31 +30,108 @@ jobs:
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract metadata
|
||||
- name: Extract metadata for backend
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/lafrite/notytex
|
||||
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/notytex-backend
|
||||
tags: |
|
||||
type=ref,event=branch,enable={{is_not_default_branch}}
|
||||
# type=ref,event=pr
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
# type=sha,prefix={{branch}}-,suffix=-{{date 'YYYYMMDD-HHmmss'}},enable={{is_default_branch}}
|
||||
type=sha,prefix={{branch}}-
|
||||
labels: |
|
||||
org.opencontainers.image.source=https://${{ env.REGISTRY }}/lafrite/notytex
|
||||
org.opencontainers.image.title=Notytex Backend
|
||||
org.opencontainers.image.description=FastAPI backend for Notytex school management system
|
||||
org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}
|
||||
org.opencontainers.image.version=${{ gitea.ref_name }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
id: build
|
||||
- name: Build and push backend image
|
||||
id: build-backend
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
registry: ${{ env.REGISTRY }}
|
||||
context: ./backend
|
||||
file: ./backend/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Image digest
|
||||
run: echo "Image pushed with digest ${{ steps.build.outputs.digest }}"
|
||||
- name: Backend image digest
|
||||
run: |
|
||||
echo "Backend image pushed with digest: ${{ steps.build-backend.outputs.digest }}"
|
||||
echo "Tags: ${{ steps.meta.outputs.tags }}"
|
||||
|
||||
build-frontend:
|
||||
name: Build Frontend Image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract metadata for frontend
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/notytex-frontend
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=sha,prefix={{branch}}-
|
||||
labels: |
|
||||
org.opencontainers.image.title=Notytex Frontend
|
||||
org.opencontainers.image.description=Vue.js frontend for Notytex school management system
|
||||
org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}
|
||||
org.opencontainers.image.version=${{ gitea.ref_name }}
|
||||
|
||||
- name: Build and push frontend image
|
||||
id: build-frontend
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./frontend
|
||||
file: ./frontend/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Frontend image digest
|
||||
run: |
|
||||
echo "Frontend image pushed with digest: ${{ steps.build-frontend.outputs.digest }}"
|
||||
echo "Tags: ${{ steps.meta.outputs.tags }}"
|
||||
|
||||
summary:
|
||||
name: Build Summary
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-backend, build-frontend]
|
||||
if: always()
|
||||
steps:
|
||||
- name: Build summary
|
||||
run: |
|
||||
echo "## 🐳 Docker Images Built Successfully"
|
||||
echo ""
|
||||
echo "### Backend Image"
|
||||
echo "- Registry: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/notytex-backend"
|
||||
echo "- Tags: latest, ${{ gitea.ref_name }}"
|
||||
echo ""
|
||||
echo "### Frontend Image"
|
||||
echo "- Registry: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/notytex-frontend"
|
||||
echo "- Tags: latest, ${{ gitea.ref_name }}"
|
||||
echo ""
|
||||
echo "### 🚀 Deployment"
|
||||
echo "docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d"
|
||||
|
||||
Reference in New Issue
Block a user