Skip to content

Commit 123437d

Browse files
committed
将站点构建迁移至 GitHub Actions (#400)
1 parent dcbb959 commit 123437d

2 files changed

Lines changed: 57 additions & 27 deletions

File tree

.drone.yml

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,23 @@ name: default
55
clone:
66
depth: 1
77

8+
trigger:
9+
branch:
10+
- pages
11+
event:
12+
- push
13+
814
steps:
9-
- name: build
10-
image: ruby:3.4
11-
environment:
12-
JEKYLL_ENV: production
13-
BUNDLE_PATH: vendor/bundle
14-
commands:
15-
- bundle config mirror.https://rubygems.org https://mirrors.cloud.tencent.com/rubygems
16-
- bundle install --verbose
17-
- bundle exec jekyll build --trace --verbose --config _config.yml,_config.drone.yml
18-
volumes:
19-
- name: dist
20-
path: /drone/src/_site
21-
- name: vendor
22-
path: /drone/src/vendor
23-
- name: jekyll-cache
24-
path: /drone/src/.jekyll-cache
25-
when:
26-
branch: [main]
15+
- name: deploy
16+
image: alpine:3.23.2
17+
volumes:
18+
- name: site
19+
path: /site
20+
commands:
21+
- rm -rf /site/*
22+
- mv ./* /site/
2723

2824
volumes:
29-
- name: dist
30-
host:
31-
path: /home/ubuntu/docs.hmcl.net/www
32-
- name: vendor
33-
host:
34-
path: /home/ubuntu/docs.hmcl.net/cache/vendor
35-
- name: jekyll-cache
36-
host:
37-
path: /home/ubuntu/docs.hmcl.net/cache/jekyll-cache
25+
- name: site
26+
host:
27+
path: /home/ubuntu/docs.hmcl.net/www

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
JEKYLL_ENV: production
10+
11+
jobs:
12+
run:
13+
if: ${{ github.repository_owner == 'HMCL-dev' }}
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
with:
21+
fetch-depth: 0
22+
- name: Setup Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: "3.4"
26+
bundler-cache: true
27+
cache-version: main
28+
- name: Build
29+
run: bundle exec jekyll build --trace --config _config.yml,_config.drone.yml --destination /home/runner/site
30+
- name: Deploy to pages branch
31+
working-directory: /home/runner/site
32+
run: |
33+
git init
34+
git checkout --orphan pages
35+
git config user.name "github-actions[bot]"
36+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
37+
git add .
38+
git commit -m "deploy: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
39+
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
40+
git push origin pages --force

0 commit comments

Comments
 (0)