-
Notifications
You must be signed in to change notification settings - Fork 2
93 lines (77 loc) · 2.24 KB
/
deploy.yaml
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
88
89
90
91
92
93
name: Deploy
on:
push:
branches:
- master
- main
jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache gems
id: cache-gems
uses: actions/cache@v4
with:
path: .bundle
key: ${{ runner.os }}-gems
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.docker_hub_username }}
password: ${{ secrets.docker_hub_password }}
- name: Build site
run: |
mkdir -p _site .bundle
docker run \
--rm \
--mount "type=bind,source=$PWD/.bundle,target=/usr/local/bundle" \
--mount "type=bind,source=$PWD,target=/srv/jekyll" \
--workdir /srv/jekyll \
"jekyll/jekyll:stable" \
jekyll build
- name: Package site
run: |
tar -czf site.tar.gz _site
sha256sum site.tar.gz >site.tar.gz.sha256
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: site
path: |
site.tar.gz
site.tar.gz.sha256
retention-days: 2
deploy:
name: Deploy
needs:
- build
runs-on: ubuntu-24.04
if: "!contains(github.event.head_commit.message, 'skip deploy')"
concurrency:
group: deploy
cancel-in-progress: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SFTPKEY }}
- name: Update known_hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan ${{ secrets.SFTPHOST }} >>~/.ssh/known_hosts
- uses: actions/download-artifact@v4
with:
name: site
- name: Upload artifact
run: |
test -f site.tar.gz
test -f site.tar.gz.sha256
echo -e "cd public_html/dille.name\nput site.tar.gz\nput site.tar.gz.sha256\npwd\ncd www\nput deploy.php\nput deploy.sh" > sftp
sftp -b sftp ${{ secrets.SFTPUSER }}@${{ secrets.SFTPHOST }}
- name: Trigger deployment
run: |
curl https://dille.name/deploy.php