55 branches : [ main ]
66 workflow_dispatch :
77
8+ permissions :
9+ contents : read
10+ packages : write
11+
812env :
9- RUBY_VERSION : ' 3.3.6'
10- NODE_VERSION : ' 20'
11- POSTGRES_VERSION : ' 17'
12- REDIS_VERSION : ' 7'
13+ RUBY_VERSION : ' 4.0.1'
14+ NODE_VERSION : ' 24'
15+ POSTGRES_VERSION : ' 18'
16+ REDIS_VERSION : ' 8'
17+ REGISTRY : ghcr.io
1318
1419jobs :
1520 test :
1823
1924 services :
2025 postgres :
21- image : postgres:17
26+ image : postgres:${{ env.POSTGRES_VERSION }}
2227 env :
2328 POSTGRES_PASSWORD : postgres
2429 POSTGRES_DB : streamsource_test
3136 - 5432:5432
3237
3338 redis :
34- image : redis:7
39+ image : redis:${{ env.REDIS_VERSION }}
3540 options : >-
3641 --health-cmd "redis-cli ping"
3742 --health-interval 10s
@@ -141,6 +146,40 @@ jobs:
141146 steps :
142147 - name : Checkout code
143148 uses : actions/checkout@v4
149+
150+ - name : Set image name
151+ id : image
152+ run : echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
153+
154+ - name : Set up QEMU
155+ uses : docker/setup-qemu-action@v3
156+
157+ - name : Set up Docker Buildx
158+ uses : docker/setup-buildx-action@v3
159+
160+ - name : Log in to GHCR
161+ uses : docker/login-action@v3
162+ with :
163+ registry : ${{ env.REGISTRY }}
164+ username : ${{ github.actor }}
165+ password : ${{ secrets.GITHUB_TOKEN }}
166+
167+ - name : Extract Docker metadata
168+ id : meta
169+ uses : docker/metadata-action@v5
170+ with :
171+ images : ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}
172+ tags : |
173+ type=sha,format=long
174+ type=raw,value=latest
175+
176+ - name : Build and push image
177+ uses : docker/build-push-action@v6
178+ with :
179+ context : .
180+ push : true
181+ tags : ${{ steps.meta.outputs.tags }}
182+ labels : ${{ steps.meta.outputs.labels }}
144183
145184 - name : Deploy to DigitalOcean
146185 id : deploy
@@ -153,16 +192,12 @@ jobs:
153192 script : |
154193 set -e
155194 cd /var/www/streamsource
195+ export STREAMSOURCE_IMAGE="${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:sha-${{ github.sha }}"
196+ export STREAMSOURCE_ENV_FILE="/var/www/streamsource/.env.production"
156197
157- # Set environment variables for deployment
158- export GITHUB_REPOSITORY="${{ github.repository }}"
159- export GITHUB_SHA="${{ github.sha }}"
160- export GITHUB_REF="${{ github.ref }}"
161-
162- # Run deployment with error handling
163- echo "🚀 Starting deployment..."
164- ./deploy/github-deploy.sh
165-
198+ echo "🚀 Pulling image ${STREAMSOURCE_IMAGE}..."
199+ docker compose -f docker-compose.yml -f docker-compose.prod.yml pull web
200+ docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d web
166201 echo "✅ Deployment completed successfully"
167202
168203 - name : Comprehensive health check
@@ -244,4 +279,4 @@ jobs:
244279 "auto_merge": false
245280 }' || echo "Failed to record deployment"
246281
247- echo "✅ Deployment metrics recorded"
282+ echo "✅ Deployment metrics recorded"
0 commit comments