forked from mariadb-corporation/mariadb-for-universities
-
Notifications
You must be signed in to change notification settings - Fork 3
67 lines (56 loc) · 2.01 KB
/
build-and-deploy.yml
File metadata and controls
67 lines (56 loc) · 2.01 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Build and Deploy Hugo Site
on:
push:
branches:
- deploy
pull_request:
workflow_dispatch: # Allows manual triggering
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout deploy branch
uses: actions/checkout@v4
with:
ref: deploy
fetch-depth: 0 # Fetch all history for proper git operations
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.136.5'
extended: false
- name: Build Hugo site
run: hugo --minify --destination html_site
- name: Check for links error
run: |
docker run --rm -t -v $(pwd):/src -w /src lycheeverse/lychee:latest \
--root-dir /src/html_site \
--exclude "(github|gitlab|www.linkedin).com" \
--exclude "^javascript:" \
-n -v html_site/**/*.html
- name: Configure Git
if: github.event_name != 'pull_request'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'github-actions@github.com'
- name: Commit and push if changed
if: github.event_name != 'pull_request'
run: |
git add html_site/
git diff --quiet && git diff --staged --quiet || (git commit -m "Build Hugo site [skip ci]" && git push)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to HZ server
if: github.event_name != 'pull_request'
run: |
# Set up SSH
mkdir -p ~/.ssh
echo "${{ secrets.KNOWN_HOST }}" > ~/.ssh/known_hosts
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
# Deploy with rsync
rsync -avz --delete -e "ssh -p ${{ secrets.SERVER_PORT }} -i ~/.ssh/deploy_key" \
html_site/ \
${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/var/www/uni.mariadb.org/
# Cleanup SSH files
rm -rf ~/.ssh/*