-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (39 loc) · 1.29 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
name: Deploy
on:
push:
# Branch on which to automatically run the deploy-action.
# ┗━ Options: branch.name ━━ example: "main"
branches: main
jobs:
setup:
runs-on: self-hosted
steps:
- uses: appleboy/ssh-action@master
with:
key: ${{ secrets.SSH_KEY }}
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
script: |
mkdir ~/env ~/env/${{github.event.repository.name}}
cd ~/env/${{github.event.repository.name}}
sudo git clone https://github.com/${{github.repository}} .
sudo git clean -f
sudo git checkout -f
sudo git pull
echo '${{ secrets.APP_ENV }}' > .env
sudo docker-compose pull
deploy:
needs: setup
runs-on: self-hosted
steps:
- uses: appleboy/ssh-action@master
with:
key: ${{ secrets.SSH_KEY }}
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ~/env/${{github.event.repository.name}}
sudo docker-compose down
sudo docker-compose up -d --remove-orphans