adding task files
هذا الالتزام موجود في:
59
q5-mithal-monitor/monitoring-workflow.yml
Normal file
59
q5-mithal-monitor/monitoring-workflow.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
name: Build, Push and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and Push Docker Image
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
|
||||
- name: Build Docker Image
|
||||
run: |
|
||||
docker build -t ${{ secrets.DOCKER_USERNAME }}/mithal-monitor:${{ github.sha }} .
|
||||
|
||||
- name: Push Docker Image
|
||||
run: |
|
||||
docker push ${{ secrets.DOCKER_USERNAME }}/mithal-monitor:${{ github.sha }}
|
||||
|
||||
deploy-production:
|
||||
name: Deploy to Production
|
||||
needs: build
|
||||
runs-on: self-hosted
|
||||
|
||||
environment:
|
||||
name: production
|
||||
|
||||
steps:
|
||||
- name: Pull Latest Image
|
||||
run: |
|
||||
docker pull ${{ secrets.DOCKER_USERNAME }}/mithal-monitor:${{ github.sha }}
|
||||
|
||||
- name: Stop Existing Container
|
||||
run: |
|
||||
docker stop mithal-monitor || true
|
||||
docker rm mithal-monitor || true
|
||||
|
||||
- name: Run New Container
|
||||
run: |
|
||||
docker run -d \
|
||||
--name mithal-monitor \
|
||||
--restart unless-stopped \
|
||||
-p 8000:8000 \
|
||||
${{ secrets.DOCKER_USERNAME }}/mithal-monitor:${{ github.sha }}
|
||||
|
||||
- name: Verify Deployment
|
||||
run: |
|
||||
docker ps
|
||||
المرجع في مشكلة جديدة
حظر مستخدم