#7 Изменение main(backend) и backend пайплайнов #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD remote | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
cd-backend: | |
if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'backend' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build backend | |
run: | | |
cd backend | |
mvn clean package | |
- name: Build and push backend image | |
run: | | |
cd backend | |
docker build -t nickpominov/lm-backend:latest . | |
docker push nickpominov/lm-backend:latest | |
- name: Deploy backend to remote server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: 22 | |
script: | | |
cd /srv/lenka-messenger | |
docker-compose -f docker-compose.prod.yaml pull lm-backend | |
docker-compose -f docker-compose.prod.yaml up -d --no-deps lm-backend | |
cd-frontend: | |
if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'frontend' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Install frontend dependencies | |
run: | | |
cd frontend | |
npm install | |
- name: Build frontend | |
run: | | |
cd frontend | |
npm run build | |
- name: Build and push frontend image | |
run: | | |
cd frontend | |
docker build -t nickpominov/lm-frontend:latest . | |
docker push nickpominov/lm-frontend:latest | |
- name: Deploy frontend to remote server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: 22 | |
script: | | |
cd /srv/lenka-messenger | |
docker-compose -f docker-compose.prod.yaml pull lm-frontend | |
docker-compose -f docker-compose.prod.yaml up -d --no-deps lm-frontend |