#7 Изменение main и frontend пайплайнов #5
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: Main CD | |
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 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: Download Backend Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: backend-jar | |
path: backend/target/ | |
- 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/ssh-action@v0.1.7 | |
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 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: Deploy frontend to remote server | |
uses: appleboy/ssh-action@v0.1.7 | |
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 up -d --no-deps lm-frontend |