Skip to content
Merged
Show file tree
Hide file tree
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
51 changes: 14 additions & 37 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,29 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

# НОВЫЙ ШАГ: Устанавливаем Node.js
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm' # Включаем кеширование для npm
cache-dependency-path: backend/package-lock.json

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# ИЗМЕНЕННЫЙ ШАГ: Логика кеширования и сборки для Node.js
- name: Build image and save as artifact
uses: docker/build-push-action@v5
with:
context: ./backend
push: false
load: true
tags: diametrfq/website-backend:latest
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
cache-from: type=gha,scope=backend-build-v1
cache-to: type=gha,mode=max,scope=backend-build-v1

- name: Save image to tar
run: docker save diametrfq/website-backend:latest -o /tmp/backend.tar
- name: Upload image artifact
Expand All @@ -69,37 +77,6 @@ jobs:
name: backend-image-${{ github.run_number }}
path: /tmp/backend.tar

push_images:
name: 3. Push Images to Docker Hub
runs-on: ubuntu-latest
needs: [build_frontend_image, build_backend_image]
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Download frontend image artifact
uses: actions/download-artifact@v4
with:
name: frontend-image-${{ github.run_number }}
path: /tmp
- name: Download backend image artifact
uses: actions/download-artifact@v4
with:
name: backend-image-${{ github.run_number }}
path: /tmp
- name: Load and Push Frontend Image
run: |
docker load --input /tmp/frontend.tar
docker push diametrfq/website:latest &
- name: Load and Push Backend Image
run: |
docker load --input /tmp/backend.tar
docker push diametrfq/website-backend:latest &
- name: Wait for all pushes to complete
run: wait

deploy_to_server:
name: 4. Deploy to Server
runs-on: ubuntu-latest
Expand Down
14 changes: 12 additions & 2 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
target
.env
# dependencies
/node_modules
/dist

# env
.env

# logs
npm-debug.log*

# misc
.DS_Store
Loading