Files
outcomes/.gitea/workflows/deploy.yml
T
YaoLei 760ba48ea6
Build and deploy Hugo site / build (push) Successful in 27s
Build and deploy Hugo site / deploy (push) Successful in 26s
Set artifact retention to 1 day
2026-07-09 13:36:06 +08:00

72 lines
2.1 KiB
YAML

name: Build and deploy Hugo site
on: [push]
jobs:
build:
runs-on: act_runner1
container:
image: learngaming.top:5000/hugo:v0.163.3
steps:
- name: Create Hugo site
run: |
set -e
hugo new site /tmp/hugo-site
- name: Setup SSH key for git clone
run: |
set -e
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -p 222 -H gitea.learngaming.top >> ~/.ssh/known_hosts
- name: Clone FixIt theme
run: |
set -e
git clone --depth=1 ssh://git@gitea.learngaming.top:222/blogs/FixIt.git /tmp/hugo-site/themes/FixIt
- name: Clone repository to content directory
run: |
set -e
REPO_URL="ssh://git@gitea.learngaming.top:222/blogs/outcomes.git"
if [ -n "${CI_REPOSITORY_URL:-}" ]; then
REPO_URL="${CI_REPOSITORY_URL}"
fi
echo "Cloning $REPO_URL to content directory"
git clone --depth=1 "$REPO_URL" /tmp/hugo-site/content
- name: Build site with Hugo
working-directory: /tmp/hugo-site
run: |
set -e
hugo --minify --theme FixIt
- name: Upload public directory
uses: actions/upload-artifact@v3
with:
name: public
path: /tmp/hugo-site/public
retention-days: 1
deploy:
runs-on: act_runner1
needs: build
container:
image: learngaming.top:5000/node-rsync:alpine
steps:
- name: Download public directory
uses: actions/download-artifact@v3
with:
name: public
path: ./public
- name: Deploy via rsync
run: |
set -e
# Setup SSH key for rsync
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H www.learngaming.top >> ~/.ssh/known_hosts
# Deploy using rsync
rsync -avz --delete ./public/ root@www.learngaming.top:/opt/1panel/www/sites/www.learngaming.top/index/