fix build frontend learner
All checks were successful
Build and Deploy Frontend Learner / Build Frontend Learner Docker Image (push) Successful in 57s
Build and Deploy Frontend Learner / Deploy E-learning Frontend Learner to Dev Server (push) Successful in 2s
Build and Deploy Frontend Learner / Notify Deployment Status (push) Successful in 1s
All checks were successful
Build and Deploy Frontend Learner / Build Frontend Learner Docker Image (push) Successful in 57s
Build and Deploy Frontend Learner / Deploy E-learning Frontend Learner to Dev Server (push) Successful in 2s
Build and Deploy Frontend Learner / Notify Deployment Status (push) Successful in 1s
This commit is contained in:
parent
9e660b0fe9
commit
058a388f4c
1 changed files with 127 additions and 17 deletions
|
|
@ -3,10 +3,10 @@ name: Build and Deploy Frontend Learner
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
paths:
|
||||
- 'Frontend-Learner/**'
|
||||
- "Frontend-Learner/**"
|
||||
- ".forgejo/workflows/deploy-frontend-learner.yaml"
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
|
|
@ -14,6 +14,13 @@ env:
|
|||
REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
|
||||
|
||||
# Docker Image
|
||||
IMAGE_NAME: chamomind/elearning-learner
|
||||
IMAGE_TAG: ${{ github.sha }}
|
||||
|
||||
# Notifications
|
||||
DISCORD_WEBHOOK_URL: ${{ vars.DISCORD_WEBHOOK_URL }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Frontend Learner Docker Image
|
||||
|
|
@ -22,6 +29,13 @@ jobs:
|
|||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ env.REGISTRY_USERNAME }}
|
||||
password: ${{ env.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
|
|
@ -30,24 +44,17 @@ jobs:
|
|||
http = true
|
||||
insecure = true
|
||||
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ env.REGISTRY_USERNAME }}
|
||||
password: ${{ env.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/elearning-frontend-learner
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=sha,prefix=
|
||||
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
|
||||
with:
|
||||
context: ./Frontend-Learner
|
||||
|
|
@ -55,20 +62,123 @@ jobs:
|
|||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
||||
|
||||
deploy:
|
||||
name: Deploy Frontend Learner to Server
|
||||
name: Deploy E-learning Frontend Learner to Dev Server
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: github.ref == 'refs/heads/dev'
|
||||
steps:
|
||||
- name: Remote Deploy
|
||||
- name: Deploy frontend learner on server
|
||||
uses: appleboy/ssh-action@v1.2.1
|
||||
with:
|
||||
host: ${{ vars.SSH_DEPLOY_HOST }}
|
||||
port: ${{ vars.SSH_DEPLOY_PORT }}
|
||||
username: ${{ secrets.SSH_DEPLOY_USER }}
|
||||
password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
|
||||
script: eval "${{ secrets.SSH_DEPLOY_FRONTEND_LEARNER_CMD }}"
|
||||
script: |
|
||||
cd ~/repo
|
||||
chmod +x ./replace-env.sh ./deploy.sh
|
||||
./replace-env.sh FRONTEND_TAG "${{ env.IMAGE_TAG }}"
|
||||
./deploy.sh elearning-learner
|
||||
|
||||
notify:
|
||||
name: Notify Deployment Status
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, deploy]
|
||||
if: always()
|
||||
steps:
|
||||
- name: Send Discord notification - Success
|
||||
if: ${{ needs.deploy.result == 'success' }}
|
||||
run: |
|
||||
curl -H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"embeds": [{
|
||||
"title": "✅ E-learning Frontend Learner Deployment Successful",
|
||||
"description": "E-learning Frontend Learner deployed to dev server",
|
||||
"color": 3066993,
|
||||
"fields": [
|
||||
{
|
||||
"name": "Environment",
|
||||
"value": "Development",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Branch",
|
||||
"value": "${{ github.ref_name }}",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Commit",
|
||||
"value": "`${{ github.sha }}`",
|
||||
"inline": false
|
||||
},
|
||||
{
|
||||
"name": "Image Tag",
|
||||
"value": "`${{ env.IMAGE_TAG }}`",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Web URL",
|
||||
"value": "${{ env.NEXT_PUBLIC_APP_URL }}",
|
||||
"inline": false
|
||||
},
|
||||
{
|
||||
"name": "Deployed By",
|
||||
"value": "${{ github.actor }}",
|
||||
"inline": true
|
||||
}
|
||||
],
|
||||
"footer": {
|
||||
"text": "CMP CD Pipeline"
|
||||
},
|
||||
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%S.000Z)"'"
|
||||
}]
|
||||
}' \
|
||||
${{ env.DISCORD_WEBHOOK_URL }}
|
||||
|
||||
- name: Send Discord notification - Failure
|
||||
if: ${{ needs.deploy.result == 'failure' || needs.build.result == 'failure' }}
|
||||
run: |
|
||||
curl -H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"embeds": [{
|
||||
"title": "❌ E-learning Frontend Learner Deployment Failed",
|
||||
"description": "Failed to deploy E-learning Frontend Learner to dev server",
|
||||
"color": 15158332,
|
||||
"fields": [
|
||||
{
|
||||
"name": "Environment",
|
||||
"value": "Development",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Branch",
|
||||
"value": "${{ github.ref_name }}",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Commit",
|
||||
"value": "`${{ github.sha }}`",
|
||||
"inline": false
|
||||
},
|
||||
{
|
||||
"name": "Failed Job",
|
||||
"value": "${{ needs.build.result == 'failure' && 'Build' || 'Deploy' }}",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Deployed By",
|
||||
"value": "${{ github.actor }}",
|
||||
"inline": true
|
||||
}
|
||||
],
|
||||
"footer": {
|
||||
"text": "CMP CD Pipeline"
|
||||
},
|
||||
"timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%S.000Z)"'"
|
||||
}]
|
||||
}' \
|
||||
${{ env.DISCORD_WEBHOOK_URL }}
|
||||
exit 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue