- Created a GitHub Actions workflow for CI/CD to deploy to Ghyamah, including testing, building, and pushing Docker images. - Added architecture design document for handling 15,000 requests per second, detailing system components, capacity planning, and cold start strategies. - Introduced a Python-based uptime/latency/SSL monitor with a static dashboard, utilizing standard libraries only. - Included Dockerfile and entrypoint script for the monitoring application, ensuring it runs as a non-root user and handles process management. - Added a .dockerignore file to exclude unnecessary files from the Docker build context. - Created an HTML dashboard for visualizing monitoring metrics, including uptime, latency, and SSL certificate status.
112 أسطر
3.3 KiB
YAML
112 أسطر
3.3 KiB
YAML
name: CI/CD Pipeline to Ghyamah
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
env:
|
|
GHYAMAH_REGISTRY: app.gitpasha.com
|
|
GHYAMAH_USERNAME: ${{ github.actor }}
|
|
ImageName: ${{ env.GHYAMAH_USERNAME }}/my-app
|
|
jobs:
|
|
###############################
|
|
# Test App Code Job
|
|
#################################
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '16'
|
|
|
|
- name: Install dependencies
|
|
run: npm install
|
|
|
|
- name: Run tests
|
|
run: npm test
|
|
|
|
- name: Build project
|
|
run: npm run build
|
|
########################################
|
|
# build and push docker image to ghyamah registry
|
|
########################################
|
|
BuildAndPush:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Log in to Ghyamah Docker registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.GHYAMAH_REGISTRY }}
|
|
username: ${{ env.GHYAMAH_USERNAME }}
|
|
password: ${{ secrets.GHYAMAH_PASSWORD }}
|
|
|
|
- name: Build and Push Docker Image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
${{ env.GHYAMAH_REGISTRY }}/${{ env.ImageName }}:${{ github.sha }}
|
|
${{ env.GHYAMAH_REGISTRY }}/${{ env.ImageName }}:latest
|
|
|
|
#################################
|
|
# Deploy to Staging and Production Jobs
|
|
#################################
|
|
|
|
deploy-staging:
|
|
runs-on: ubuntu-latest
|
|
needs: BuildAndPush
|
|
steps:
|
|
- name: Install Ghyamah CLI
|
|
run: |
|
|
curl -sSL https://get.ghaymah.systems/cli/install.sh | sh
|
|
echo "$HOME/.ghaymah/bin" >> $GITHUB_PATH
|
|
- name: Log in to Ghyamah
|
|
run: |
|
|
ghyamah login --username ${{ env.GHYAMAH_USERNAME }} --password ${{ secrets.GHYAMAH_PASSWORD }}
|
|
|
|
- name: Deploy to Staging
|
|
env:
|
|
GHYAMAH_TOKEN: ${{ secrets.GHYAMAH_PASSWORD }}
|
|
run: |
|
|
ghayamah app update my-staging-app --image ${{ env.GHYAMAH_REGISTRY }}/${{ env.ImageName }}:latest
|
|
|
|
|
|
|
|
#######################################
|
|
# Deploy to Production Job with Manual Approval
|
|
#######################################
|
|
deploy-production:
|
|
runs-on: ubuntu-latest
|
|
needs: BuildAndPush
|
|
steps:
|
|
- name: Wait for Manual Approval
|
|
uses: trstringer/manual-approval@v1
|
|
with:
|
|
secret: ${{ secrets.GHYAMAH_PASSWORD }}
|
|
issue-title: "Approval Required for Deployment to Production"
|
|
issue-body: "Please review the changes and approve the deployment to production."
|
|
- name: Install Ghyamah CLI
|
|
run: |
|
|
curl -sSL https://get.ghaymah.systems/cli/install.sh | sh
|
|
echo "$HOME/.ghaymah/bin" >> $GITHUB_PATH
|
|
- name: Log in to Ghyamah
|
|
run: |
|
|
ghyamah login --username ${{ env.GHYAMAH_USERNAME }} --password ${{ secrets.GHYAMAH_PASSWORD }}
|
|
|
|
- name: Deploy to Production
|
|
env:
|
|
GHYAMAH_TOKEN: ${{ secrets.GHYAMAH_PASSWORD }}
|
|
run: |
|
|
ghayamah app update my-production-app --image ${{ env.GHYAMAH_REGISTRY }}/${{ env.ImageName }}:latest |