将站点构建迁移至 GitHub Actions (#400)

This commit is contained in:
neveler 2026-03-15 11:42:03 +08:00 committed by GitHub
parent c448a6beb8
commit 34b9692db7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 57 additions and 27 deletions

View File

@ -5,33 +5,23 @@ name: default
clone: clone:
depth: 1 depth: 1
trigger:
branch:
- pages
event:
- push
steps: steps:
- name: build - name: deploy
image: ruby:3.4 image: alpine:3.23.2
environment: volumes:
JEKYLL_ENV: production - name: site
BUNDLE_PATH: vendor/bundle path: /site
commands: commands:
- bundle config mirror.https://rubygems.org https://mirrors.cloud.tencent.com/rubygems - rm -rf /site/*
- bundle install --verbose - mv ./* /site/
- bundle exec jekyll build --trace --verbose --config _config.yml,_config.drone.yml
volumes:
- name: dist
path: /drone/src/_site
- name: vendor
path: /drone/src/vendor
- name: jekyll-cache
path: /drone/src/.jekyll-cache
when:
branch: [main]
volumes: volumes:
- name: dist - name: site
host: host:
path: /home/ubuntu/docs.hmcl.net/www path: /home/ubuntu/docs.hmcl.net/www
- name: vendor
host:
path: /home/ubuntu/docs.hmcl.net/cache/vendor
- name: jekyll-cache
host:
path: /home/ubuntu/docs.hmcl.net/cache/jekyll-cache

40
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: Build
on:
push:
branches:
- main
env:
JEKYLL_ENV: production
jobs:
run:
if: ${{ github.repository_owner == 'HMCL-dev' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
cache-version: main
- name: Build
run: bundle exec jekyll build --trace --config _config.yml,_config.drone.yml --destination /home/runner/site
- name: Deploy to pages branch
working-directory: /home/runner/site
run: |
git init
git checkout --orphan pages
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "deploy: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push origin pages --force