-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (42 loc) · 1.34 KB
/
deploy.yml
File metadata and controls
48 lines (42 loc) · 1.34 KB
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: Deployment-Action
on:
# push:
# branches:
# - main
release:
types: [published]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Prepare ssh keys
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Get latest release
uses: robinraju/release-downloader@v1.3
with:
repository: ${{github.repository}}
latest: true
tarBall: true
- name: Unzip latest release
run: |
ls -la *.tar.gz
tarball="$(ls *.tar.gz)"
tar -xvz --strip-components=1 -f "${tarball}"
rm "${tarball}"
- name: Grap .env
run: |
echo "${{ secrets.DOTENV }}" > .env
- name: Push to Server
run: |
eval "${{ secrets.DEPLOY_TARGET }}"
rsync -avz -e "ssh -p ${DEPLOY_PORT-22}" --exclude ".git/" --exclude ".github/" --exclude ".env.example" \
. ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}
- name: Restart Server
run: |
eval "${{ secrets.DEPLOY_TARGET }}"
ssh -p ${DEPLOY_PORT-2} ${DEPLOY_USER}@${DEPLOY_HOST} bash -c \
"cd ${DEPLOY_PATH}/.. && docker-compose build && docker-compose stop --remove-orphans && docker-compose up -d"