Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: Build, Push, and Deploy (5 Separate Jobs)
name: Build, Push, and Deploy

on:
pull_request:
branches:
- main

env:
DOCKER_BUILD_RECORD_RETENTION_DAYS: 1
BUILDX_CACHE_MAX_SIZE: 5GB
ACTIONS_CACHE_KEY_PREFIX: v1

jobs:
build_frontend_image:
name: 1. Build Frontend Image
Expand All @@ -21,14 +26,18 @@ jobs:
push: false
load: true
tags: diametrfq/website:latest
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: |
type=gha,scope=frontend-build-${{ hashFiles('frontend/**') }}
type=gha,scope=frontend-build
cache-to: |
type=gha,mode=max,scope=frontend-build-${{ hashFiles('frontend/**') }}
type=gha,mode=min,scope=frontend-build
- name: Save image to tar
run: docker save diametrfq/website:latest -o /tmp/frontend.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: frontend-image
name: frontend-image-${{ github.run_number }}
path: /tmp/frontend.tar

build_backend_image:
Expand All @@ -46,14 +55,18 @@ jobs:
push: false
load: true
tags: diametrfq/website-backend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: |
type=gha,scope=backend-build-${{ hashFiles('backend/**') }}
type=gha,scope=backend-build
cache-to: |
type=gha,mode=max,scope=backend-build-${{ hashFiles('backend/**') }}
type=gha,mode=min,scope=backend-build
- name: Save image to tar
run: docker save diametrfq/website-backend:latest -o /tmp/backend.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: backend-image
name: backend-image-${{ github.run_number }}
path: /tmp/backend.tar

push_frontend_image:
Expand All @@ -69,7 +82,7 @@ jobs:
- name: Download frontend image artifact
uses: actions/download-artifact@v4
with:
name: frontend-image
name: frontend-image-${{ github.run_number }}
path: /tmp
- name: Load and Push Frontend Image
run: |
Expand All @@ -89,7 +102,7 @@ jobs:
- name: Download backend image artifact
uses: actions/download-artifact@v4
with:
name: backend-image
name: backend-image-${{ github.run_number }}
path: /tmp
- name: Load and Push Backend Image
run: |
Expand Down Expand Up @@ -134,3 +147,18 @@ jobs:

echo "Cleaning up old images..."
docker system prune -af

cleanup_artifacts:
name: 6. Cleanup Artifacts
runs-on: ubuntu-latest
needs: [deploy_to_server]
if: always()
steps:
- name: Delete build artifacts from current run
uses: geekyeggo/delete-artifact@v5
with:
name: |
frontend-image-${{ github.run_number }}
backend-image-${{ github.run_number }}
useGlob: false
failOnError: false
Loading