-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (40 loc) · 1.44 KB
/
deploy-production.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
name: vps-deploy
on:
push:
branches: ['main']
workflow_dispatch:
env:
SERVER_IMAGE_NAME: prochainweb-server:latest
CLIENT_IMAGE_NAME: prochainweb-client:latest
jobs:
publish:
name: publish docker images
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Login to DockerHub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Build and push server image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/$SERVER_IMAGE_NAME -f server/Dockerfile.production server/
docker push ${{ secrets.DOCKERHUB_USERNAME }}/$SERVER_IMAGE_NAME
- name: Build and push client image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/$CLIENT_IMAGE_NAME -f client/Dockerfile.production client/
docker push ${{ secrets.DOCKERHUB_USERNAME }}/$CLIENT_IMAGE_NAME
deploy:
needs: publish
name: deploy image in remote vps
runs-on: ubuntu-latest
steps:
- name: SSH into remote server and deploy
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.REMOTE_SSH_HOST }}
username: ${{ secrets.REMOTE_SSH_USER }}
password: ${{ secrets.REMOTE_SSH_PASSWORD }}
port: 22
script: |
cd ${{ secrets.REMOTE_WORKING_DIRECTORY }}
./deploy-production.sh