forked from Iryna-Gry/fix-lab-project
-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (36 loc) · 1.86 KB
/
ssh-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: CI/CD Deploy Pipeline # The name of the workflow
on:
pull_request:
types:
- closed
workflow_dispatch:
jobs:
deploy:
name: "Publish Application"
runs-on: ubuntu-latest
steps:
- name: "Run deploy on SSH"
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'deployment'
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
script: |
cd app
echo ${{ secrets.REGISTRY_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'backend') }}" == "true" ]]; then
docker rm $(docker stop $(docker ps -a -q --filter ancestor=ghcr.io/dmytro-komlyk/prod-fixlab-server:latest ))
docker rmi ghcr.io/dmytro-komlyk/prod-fixlab-server:latest
fi
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'frontend-client') }}" == "true" ]]; then
docker rm $(docker stop $(docker ps -a -q --filter ancestor=ghcr.io/dmytro-komlyk/prod-fixlab-client:latest ))
docker rmi ghcr.io/dmytro-komlyk/prod-fixlab-client:latest
fi
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'frontend-admin') }}" == "true" ]]; then
docker rm $(docker stop $(docker ps -a -q --filter ancestor=ghcr.io/dmytro-komlyk/prod-fixlab-admin:latest ))
docker rmi ghcr.io/dmytro-komlyk/prod-fixlab-admin:latest
fi
docker compose -f docker-compose.prod-ci.yml -p fix-lab-prod pull
docker compose -f docker-compose.prod-ci.yml -p fix-lab-prod up -d