-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (50 loc) · 1.68 KB
/
ci.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
name: Hugo site CI
on:
push:
branches:
- master
- preview
pull_request:
branches:
- master
- preview
jobs:
build_job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.119.0'
- uses: Wohlstand/[email protected]
- name: Build site
run: chmod +x ci-build.sh && ./ci-build.sh ${{ github.sha }} ${{ github.run_id }} ${{ env.BRANCH_NAME }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build
path: build
deploy:
runs-on: ubuntu-latest
needs: build_job
steps:
- uses: actions/download-artifact@v4
with:
name: build
path: /home/runner/work/blog/blog/build
- name: "Prepare SSH key and known hosts"
# https://github.com/symfony/cli/issues/227#issuecomment-601680974
run: |
mkdir -p ~/.ssh
echo "${{ secrets.KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan ${{ secrets.HOST }} >> ~/.ssh/known_hosts
- uses: Wohlstand/[email protected]
- name: Run deploy script
run: |
rsync -rSlh --stats build/ ${{ secrets.USERNAME }}@${{ secrets.HOST }}:${{ secrets.WEBPATH }}-${{ env.BRANCH_NAME }}/tar
ssh -o StrictHostKeyChecking=yes ${{ secrets.USERNAME }}@${{ secrets.HOST }} 'bash -s' -- < build/ci-deploy.sh ${{ secrets.WEBPATH }}-${{ env.BRANCH_NAME }}