This commit is contained in:
2026-03-21 17:33:39 +03:30
parent 451a814347
commit 1f08a80c72
5 changed files with 145 additions and 188 deletions
+62 -72
View File
@@ -1,72 +1,62 @@
name: Frontend CI/CD
on:
push:
branches: [main]
paths:
- 'frontend/**'
- 'frontend/.github/workflows/frontend.yml'
pull_request:
branches: [main]
paths:
- 'frontend/**'
- 'frontend/.github/workflows/frontend.yml'
defaults:
run:
working-directory: frontend
jobs:
build:
name: Build, Lint & Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node-version: ['20']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-frontend-${{ hashFiles('frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-frontend-
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Lint
run: npm run lint --if-present
- name: Test
run: npm test --if-present
deploy:
name: Deploy Frontend
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /opt/myproject/frontend
git pull origin main
sudo systemctl restart frontend
name: Frontend CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
name: Build & Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint --if-present
- name: Build
run: npm run build
deploy:
name: Deploy Frontend
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -p ${{ secrets.SERVER_SSH_PORT }} -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
- name: Deploy
run: |
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} -p ${{ secrets.SERVER_SSH_PORT }} << 'EOF'
cd ${{ secrets.PROJECT_PATH }}/frontend
git pull origin main
docker compose -f docker-compose-prod.yml down
docker compose -f docker-compose-prod.yml up -d --build
EOF