الملفات
ghaymah-exam-abdelaziz-sre/q3-cicd/workflow.yml

60 أسطر
1.6 KiB
YAML

name: Build and Deploy Docker Image
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Login to Ghaymah Container Registry
run: |
echo "${{ secrets.GHAYMAH_PASSWORD }}" | docker login registry.ghaymah.systems \
-u "${{ secrets.GHAYMAH_USERNAME }}" \
--password-stdin
- name: Build Docker Image
run: |
docker build -t registry.ghaymah.systems/my-api:${{ github.sha }} .
- name: Push Docker Image
run: |
docker push registry.ghaymah.systems/my-api:${{ github.sha }}
deploy-staging:
needs: build
runs-on: ubuntu-latest
environment:
name: staging
steps:
- name: Deploy to Staging
run: |
echo "Deploying image ${{ github.sha }} to staging..."
# ghaymah deploy my-api-staging --image registry.ghaymah.systems/my-api:${{ github.sha }}
deploy-production:
needs: deploy-staging
runs-on: ubuntu-latest
# This "environment: production" line by itself does NOT block the job.
# The manual approval only happens if you also configure, on GitHub:
# Settings -> Environments -> production -> Required reviewers
# Add yourself (or a teammate) as a required reviewer there.
# Without that step, this environment tag is just a label.
environment:
name: production
steps:
- name: Deploy to Production
run: |
echo "Deploying image ${{ github.sha }} to production..."
# ghaymah deploy my-api --image registry.ghaymah.systems/my-api:${{ github.sha }}