-
Notifications
You must be signed in to change notification settings - Fork 4
72 lines (65 loc) · 1.87 KB
/
staging-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
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Web deploy
on:
push:
branches: [ staging ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: staging
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install
run: npm ci
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: staging
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: stagecodes
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
run: |
docker build -t stagecodes/otr-web-staging:latest .
docker push stagecodes/otr-web-staging:latest
deploy:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: staging
- name: Create .env files
run: |
echo "${{ secrets.STAGING_APP_ENV }}" > .env
- name: Copy files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.STAGING_SSH_HOST }}
username: ${{ secrets.STAGING_SSH_USER }}
key: ${{ secrets.STAGING_SSH_KEY }}
source: ".env"
target: "~/otr-web/"
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.STAGING_SSH_HOST }}
username: ${{ secrets.STAGING_SSH_USER }}
key: ${{ secrets.STAGING_SSH_KEY }}
script: |
docker pull stagecodes/otr-web-staging:latest
docker stop otr-web-staging || true
docker rm otr-web-staging || true
docker run -d -p 3000:3000 --name otr-web-staging --env-file ~/otr-web/.env stagecodes/otr-web-staging:latest