-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (72 loc) · 2 KB
/
main.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Fetch & Deploy to gis.ee/sadamad/
on:
schedule:
- cron: "25 5 * * 1,4"
push:
branches:
- master
workflow_dispatch:
jobs:
fetch:
name: Fetch
runs-on: ubuntu-latest
outputs:
ok: ${{ steps.check.outputs.ok }}
steps:
- name: Checkout to main
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Fetch files
run: npm run start
- name: Upload fetched files
uses: actions/upload-artifact@v4
with:
name: ports-files
path: ./public
- name: Check git status
id: check
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "ok=1" >> $GITHUB_OUTPUT
fi
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: fetch
if: needs.fetch.outputs.ok
environment:
name: production
url: https://gis.ee/sadamad/
steps:
- name: Checkout to main
uses: actions/checkout@v4
- name: Download built files
uses: actions/download-artifact@v4
with:
name: ports-files
path: ./public
- name: Set current date
id: date
run: |
echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Push data to git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Data update ${{ steps.date.outputs.today }}"
git push
- name: Connect to server over SSH
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.HOST }} >> ~/.ssh/known_hosts
- name: Deploy files
run: |
rsync -vrm ./public/ ${{ secrets.USERNAME }}@${{ secrets.HOST }}:${{ secrets.PATH }}