هذا الالتزام موجود في:
2026-07-28 13:34:58 +03:00
التزام 1150963ef4
20 ملفات معدلة مع 674 إضافات و0 حذوفات

17
q3-cicd/.ghaymah.json Normal file
عرض الملف

@@ -0,0 +1,17 @@
{
"id": "9299b6b6-ff2e-4984-8d85-5bdb0b809533",
"name": "q3",
"projectId": "27aacb50-4d56-474c-baae-b52a853b4d57",
"ports": [
{
"expose": true,
"number": 3000
}
],
"publicAccess": {
"enabled": true,
"domain": "auto"
},
"resourceTier": "t1",
"dockerFileName": "Dockerfile"
}

55
q3-cicd/.github/workflows/ci.yml مباع Normal file
عرض الملف

@@ -0,0 +1,55 @@
name: Ghaymah CI/CD Pipeline
on:
push:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
deploy-staging:
name: Deploy to Staging
needs: build
runs-on: ubuntu-latest
# Staging is used for pre-production validation before a live release.
environment:
name: staging
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Ghaymah CLI
run: curl -sSL https://cli.ghaymah.systems/install.sh | bash
- name: Login to Ghaymah
run: $HOME/ghaymah/bin/gy auth login --email "${{ secrets.GHAYMAH_EMAIL }}" --password "${{ secrets.GHAYMAH_PW }}" --debug
deploy-production:
name: Deploy to Production
needs: deploy-staging
runs-on: ubuntu-latest
# Production is the live environment and should be protected by manual approval.
environment:
name: production
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Ghaymah CLI
run: curl -sSL https://cli.ghaymah.systems/install.sh | bash
- name: Login to Ghaymah
run: $HOME/ghaymah/bin/gy auth login --email "${{secrets.GHAYMAH_EMAIL}}" --password "${{secrets.GHAYMAH_PW}}" --debug
- name: Deploy to Ghaymah (Production)
run: $HOME/ghaymah/bin/gy resource app launch --debug

18
q3-cicd/Dockerfile Normal file
عرض الملف

@@ -0,0 +1,18 @@
# Use a lightweight Node base image
FROM node:18-alpine
# Set the working directory inside the container
WORKDIR /usr/src/app
# Copy dependency definitions and install them
COPY package*.json ./
RUN npm install --production
# Copy the application code
COPY . .
# Expose the API port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]

50
q3-cicd/README.md Normal file
عرض الملف

@@ -0,0 +1,50 @@
# Ghaymah CI/CD Guide
## Staging vs. Production
- Staging is a pre-production environment used to test changes safely before they reach real users. It is typically isolated from production data and traffic, so teams can validate deployments, configuration, and application behavior without affecting live services.
- Production is the live environment that serves real users and business-critical traffic. Deployments here should be controlled carefully, usually with approval gates, protected environments, and rollback plans.
- A common release flow is:
1. Build and test the application.
2. Deploy to staging.
3. Validate the release.
4. Request approval for production.
5. Deploy to production.
## Connecting the GitHub Actions workflow to Ghaymah CLI
The workflow uses the Ghaymah CLI to authenticate and deploy the app.
### 1. Add GitHub secrets
Create these repository or environment secrets in GitHub:
- GHAYMAH_EMAIL
- GHAYMAH_PW
### 2. Install the CLI
The workflow installs the CLI during the deployment job:
```bash
curl -sSL https://cli.ghaymah.systems/install.sh | bash
```
### 3. Authenticate with Ghaymah
After installation, the workflow logs in with the stored credentials:
```bash
$HOME/ghaymah/bin/gy auth login --email "${{ secrets.GHAYMAH_EMAIL }}" --password "${{ secrets.GHAYMAH_PW }}" --debug
```
### 4. Deploy the application
The deployment step then launches the app through Ghaymah:
```bash
$HOME/ghaymah/bin/gy resource app launch --debug
```
### 5. Recommended GitHub environment setup
Use GitHub Environments for deployment control:
- Create a staging environment for regular validation.
- Create a production environment and require manual approval before deployment.
- Attach the same secrets to the relevant environment when needed.

18
q3-cicd/package.json Normal file
عرض الملف

@@ -0,0 +1,18 @@
{
"name": "q1-deploy-monitor",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.18.2"
}
}

23
q3-cicd/server.js Normal file
عرض الملف

@@ -0,0 +1,23 @@
const express = require('express');
const cors = require('cors');
const app = express();
const port = process.env.PORT || 3000;
let requestCount = 0;
let totalResponseTime = 0;
// cors
app.use(cors());
// The requested health endpoint
app.get('/health', (req, res) => {
res.status(200).json({ status: 'UP', timestamp: new Date().toISOString() });
});
app.listen(port, () => {
console.log(`API running on port ${port}`);
});