-
Notifications
You must be signed in to change notification settings - Fork 2
59 lines (52 loc) · 1.91 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Build & Deploy to VPS
on:
push:
branches:
- main
env:
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-images:
runs-on: ubuntu-latest
strategy:
matrix:
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push Images
run: |
cd docker/frontend
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/portfolio-frontend:latest .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/portfolio-frontend:latest
ls
cd ../../docker/nginx
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/portfolio-nginx:latest .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/portfolio-nginx:latest
- name: Build and Push Nginx Image
run: |
deploy:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Login via SSH and deploy on server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ~/deployments/portfolio
docker compose pull
docker compose down
docker compose up -d