-
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (59 loc) · 2 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
60
61
62
63
64
65
66
67
68
69
name: Lint and Deploy to Hosted server
on:
push:
branches: [ main ]
workflow_dispatch:
permissions: write-all
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Declare commit sha variables
id: vars
shell: bash
run: echo "::set-output name=sha::$(echo ${GITHUB_SHA})"
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Check if changes were made
id: check-changes
run: |
if [ -z "$(git diff --name-only HEAD)" ]; \
then echo '::set-output name=changed::false'; \
else echo '::set-output name=changed::true'; fi
- name: Commit files
if: steps.check-changes.outputs.changed == 'true'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -am ":rotating_light: Lint - ${{ steps.vars.outputs.sha }}"
- name: Push changes
if: steps.check-changes.outputs.changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.gh_token }}
branch: ${{ github.ref }}
- name: Deploy
if: steps.check-changes.outputs.changed == 'false'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASS }}
port: ${{ secrets.SERVER_PORT }}
script_stop: true
script: |
cd ${{ secrets.SERVER_PATH }}
git checkout .
git pull
docker compose down --remove-orphans
docker compose build
docker compose -f docker-compose.yml up -d --force-recreate