👋 update workflow to use vars and secrets not just secrets
Some checks failed
Build and Deploy Next.js Blog to Production / 🔍 Code Quality Checks (push) Failing after 44s
Build and Deploy Next.js Blog to Production / 🏗️ Build and Push Docker Image (push) Has been skipped
Build and Deploy Next.js Blog to Production / 🚀 Deploy to Production (push) Has been skipped

This commit was merged in pull request #6.
This commit is contained in:
RJ
2025-11-19 15:46:08 +02:00
parent 3136131182
commit 5be30eb8c4
2 changed files with 22 additions and 22 deletions

View File

@@ -96,11 +96,11 @@ jobs:
# - Uses Dockerfile.nextjs from project root # - Uses Dockerfile.nextjs from project root
# - Tags image with both 'latest' and commit SHA # - Tags image with both 'latest' and commit SHA
# - Enables inline cache for faster subsequent builds # - Enables inline cache for faster subsequent builds
# -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} ❗ do this if deploying on PR creation
docker build \ docker build \
--progress=plain \ --progress=plain \
--build-arg BUILDKIT_INLINE_CACHE=1 \ --build-arg BUILDKIT_INLINE_CACHE=1 \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
-f Dockerfile.nextjs \ -f Dockerfile.nextjs \
. .
@@ -114,11 +114,11 @@ jobs:
# Push both tags (latest and commit SHA) # Push both tags (latest and commit SHA)
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} # docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
echo "✅ Image pushed successfully" echo "✅ Image pushed successfully"
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" # echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
# ============================================ # ============================================
# Job 2: Deploy to Production Server # Job 2: Deploy to Production Server
@@ -129,7 +129,7 @@ jobs:
needs: [build-and-push] # Wait for build job to complete needs: [build-and-push] # Wait for build job to complete
environment: environment:
name: production name: production
url: http://your-production-url.com # Update with your actual production URL url: http://192.168.1.54:3030 # Update with your actual production URL
steps: steps:
- name: 🔎 Checkout code (for docker-compose file) - name: 🔎 Checkout code (for docker-compose file)
@@ -142,8 +142,8 @@ jobs:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_URL: ${{ env.REGISTRY }} REGISTRY_URL: ${{ env.REGISTRY }}
with: with:
host: ${{ secrets.PRODUCTION_HOST }} host: ${{ vars.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USER }} username: ${{ vars.PRODUCTION_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }} key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22 port: 22
envs: REGISTRY_PASSWORD,REGISTRY_USERNAME,REGISTRY_URL envs: REGISTRY_PASSWORD,REGISTRY_USERNAME,REGISTRY_URL
@@ -163,8 +163,8 @@ jobs:
- name: 📁 Ensure application directory structure - name: 📁 Ensure application directory structure
uses: appleboy/ssh-action@v1.0.3 uses: appleboy/ssh-action@v1.0.3
with: with:
host: ${{ secrets.PRODUCTION_HOST }} host: ${{ vars.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USER }} username: ${{ vars.PRODUCTION_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }} key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22 port: 22
script: | script: |
@@ -198,8 +198,8 @@ jobs:
- name: 📦 Copy docker-compose.prod.yml to server - name: 📦 Copy docker-compose.prod.yml to server
uses: appleboy/scp-action@v0.1.7 uses: appleboy/scp-action@v0.1.7
with: with:
host: ${{ secrets.PRODUCTION_HOST }} host: ${{ vars.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USER }} username: ${{ vars.PRODUCTION_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }} key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22 port: 22
source: "docker-compose.prod.yml" source: "docker-compose.prod.yml"
@@ -214,8 +214,8 @@ jobs:
REGISTRY_URL: ${{ env.REGISTRY }} REGISTRY_URL: ${{ env.REGISTRY }}
IMAGE_FULL: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest IMAGE_FULL: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
with: with:
host: ${{ secrets.PRODUCTION_HOST }} host: ${{ vars.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USER }} username: ${{ vars.PRODUCTION_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }} key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22 port: 22
envs: REGISTRY_PASSWORD,REGISTRY_USERNAME,REGISTRY_URL,IMAGE_FULL envs: REGISTRY_PASSWORD,REGISTRY_USERNAME,REGISTRY_URL,IMAGE_FULL
@@ -272,8 +272,8 @@ jobs:
- name: ❤️ Health check - name: ❤️ Health check
uses: appleboy/ssh-action@v1.0.3 uses: appleboy/ssh-action@v1.0.3
with: with:
host: ${{ secrets.PRODUCTION_HOST }} host: ${{ vars.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USER }} username: ${{ vars.PRODUCTION_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }} key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22 port: 22
script: | script: |

View File

@@ -67,14 +67,14 @@ services:
# Resource limits for production # Resource limits for production
# Prevents container from consuming all server resources # Prevents container from consuming all server resources
deploy: # deploy:
resources: # resources:
limits: # limits:
cpus: '1.0' # Maximum 1 CPU core # cpus: '1.0' # Maximum 1 CPU core
memory: 512M # Maximum 512MB RAM # memory: 512M # Maximum 512MB RAM
reservations: # reservations:
cpus: '0.25' # Reserve at least 0.25 CPU cores # cpus: '0.25' # Reserve at least 0.25 CPU cores
memory: 256M # Reserve at least 256MB RAM # memory: 256M # Reserve at least 256MB RAM
# Network configuration # Network configuration
networks: networks: