Updating CICD Workflow
فشلت بعض الفحوصات
/ build_and_push_image (push) Failing after 35s
/ deploy (push) Has been skipped

هذا الالتزام موجود في:
ahmedgamalyousef
2025-10-07 23:13:46 +03:00
الأصل f96cdb4a63
التزام b1f32884cc

عرض الملف

@@ -1,177 +1,36 @@
name: Deploy to Ghaymah Cloud
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
env:
# These can be overridden in repository variables
APP_NAME: ${{ github.event.repository.name }}
APP_PORT: 3000
DOCKER_IMAGE: ${{ github.repository }}
jobs:
build-and-push:
name: Build and Push Docker Image
# runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.version.outputs.IMAGE_TAG }}
short_sha: ${{ steps.version.outputs.SHORT_SHA }}
build_and_push_image:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: checkout code
uses: actions/checkout@v5.0.0
- name: Extract metadata and version
id: version
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
TIMESTAMP=$(date +%Y%m%d%H%M%S)
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "IMAGE_TAG=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_IMAGE }}:${SHORT_SHA}-${TIMESTAMP}" >> $GITHUB_OUTPUT
echo "LATEST_TAG=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_IMAGE }}:latest" >> $GITHUB_OUTPUT
echo "📦 Version: ${SHORT_SHA}-${TIMESTAMP}"
- name: login to dockerhub
uses: docker/login-action@v3.6.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ steps.version.outputs.IMAGE_TAG }}
${{ steps.version.outputs.LATEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Show image info
run: |
echo "✅ Image built and pushed:"
echo " Versioned: ${{ steps.version.outputs.IMAGE_TAG }}"
echo " Latest: ${{ steps.version.outputs.LATEST_TAG }}"
deploy-to-ghaymah:
name: Deploy to Ghaymah
# runs-on: ubuntu-latest
needs: build-and-push
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ahmedgamalyousef/Weatherapp:latest
deploy:
needs: build_and_push_image
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: checkout code
uses: actions/checkout@v5.0.0
- name: install ghaymah cli
run: curl -sSl https://cli.ghaymah.systems/install.sh | bash
- name: Install Ghaymah CLI
run: |
echo "📥 Installing Ghaymah CLI..."
curl -sSL https://cli.ghaymah.systems/install.sh | bash
echo "✅ Ghaymah CLI installed"
- name: login to ghaymah
run: $HOME/ghaymah/bin/gy auth login --email "${{secrets.GHAYMAH_EMAIL}}" --password "${{secrets.GHAYMAH_PASSWORD}}"
- name: Configure Ghaymah authentication
run: |
echo "🔐 Setting up Ghaymah authentication..."
$HOME/ghaymah/bin/gy auth login --email "${{ secrets.GHAYMAH_EMAIL }}" --password "${{ secrets.GHAYMAH_PASSWORD }}"
echo "✅ Authenticated with Ghaymah"
- name: Create or get project
id: project
run: |
echo "🏗️ Setting up project..."
# Use repository name as project name, or custom from secrets
PROJECT_NAME="${{ secrets.GHAYMAH_PROJECT_NAME || github.event.repository.name }}"
# Check if project exists
if $HOME/ghaymah/bin/gy resource project get --name "$PROJECT_NAME" > /dev/null 2>&1; then
echo "✅ Using existing project: $PROJECT_NAME"
PROJECT_ID=$($HOME/ghaymah/bin/gy resource project get --name "$PROJECT_NAME" | grep -oP 'ID:\s*\K[^\s]+' || echo "")
else
echo "📝 Creating new project: $PROJECT_NAME"
PROJECT_ID=$($HOME/ghaymah/bin/gy resource project create --set .name="$PROJECT_NAME" | grep -oP 'ID:\s*\K[^\s]+')
fi
if [ -z "$PROJECT_ID" ]; then
echo "❌ Failed to get project ID"
exit 1
fi
echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_OUTPUT
echo "PROJECT_NAME=$PROJECT_NAME" >> $GITHUB_OUTPUT
echo "✅ Project ID: $PROJECT_ID"
- name: Create Ghaymah configuration
run: |
echo "⚙️ Creating deployment configuration..."
# Use custom app name or default to repository name
APP_NAME="${{ secrets.GHAYMAH_APP_NAME || env.APP_NAME }}"
APP_PORT="${{ env.APP_PORT }}"
IMAGE_TAG="${{ needs.build-and-push.outputs.image_tag }}"
PROJECT_ID="${{ steps.project.outputs.PROJECT_ID }}"
cat > .ghaymah.json << EOF
{
"container": {
"image": "$IMAGE_TAG",
"pullSecretName": ""
},
"name": "$APP_NAME",
"ports": [
{
"expose": true,
"number": $APP_PORT
}
],
"projectId": "$PROJECT_ID",
"publicAccess": {
"baseDomain": "hosted.ghaymah.systems",
"domain": "auto",
"enabled": true
},
"resourceTier": "t1"
}
EOF
echo "✅ Configuration file created:"
echo " App: $APP_NAME"
echo " Port: $APP_PORT"
echo " Image: $IMAGE_TAG"
echo " Project: $PROJECT_ID"
- name: Deploy application
run: |
echo "🚀 Deploying to Ghaymah..."
$HOME/ghaymah/bin/gy resource app launch
echo "✅ Deployment initiated"
- name: Wait for deployment
run: |
echo "⏳ Waiting for deployment to complete..."
sleep 30
APP_NAME="${{ secrets.GHAYMAH_APP_NAME || env.APP_NAME }}"
echo "🌐 Your app should be available at: https://${APP_NAME}.hosted.ghaymah.systems"
- name: Show deployment summary
run: |
echo ""
echo "🎉 DEPLOYMENT COMPLETE!"
echo "========================"
echo "📱 Application: ${{ secrets.GHAYMAH_APP_NAME || env.APP_NAME }}"
echo "🏗️ Project: ${{ steps.project.outputs.PROJECT_NAME }}"
echo "🐳 Image: ${{ needs.build-and-push.outputs.image_tag }}"
echo "🔗 Commit: ${{ github.sha }}"
echo "🌐 URL: https://${{ secrets.GHAYMAH_APP_NAME || env.APP_NAME }}.hosted.ghaymah.systems"
echo "========================"
- name: deploy
run: $HOME/ghaymah/bin/gy resource app launch