doc/笔记/hugo基于gitea.md

88 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 注册Runner
```sh
./act_runner-0.2.5-linux-amd64 --config config.yaml register
```
运行runner
```sh
nohup act_runner-0.2.5-linux-amd64 >/dev/null 2>&1 &
```
runner配置其中labels为ubuntu-22.04:host 参照官方文档,这个可以用,意为在本地主机执行作业
```json
{
"WARNING": "This file is automatically generated by act-runner. Do not edit it manually unless you know what you are doing. Removing this file will cause act runner to re-register as a new runner.",
"id": 11,
"uuid": "3706a8fe-6d58-402a-bef1-7250497aea67",
"name": "test_build",
"token": "ceab31c3fbf94c7c5f03dcc9af3a87eb0f257370",
"address": "http://43.154.19.134:3000/",
"labels": [
"ubuntu-22.04:host"
]
}
```
# Docker方式注册Runner
```dockerfile
docker run \
-v $PWD/config.yaml:/config.yaml \
-v $PWD/data:/data \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/local/hugo/blog:/usr/local/hugo/blog
-v /var/www/blog:/var/www/blog
-e CONFIG_FILE=/config.yaml \
-e GITEA_INSTANCE_URL=<instance_url> \
-e GITEA_RUNNER_REGISTRATION_TOKEN=<registration_token> \
-e GITEA_RUNNER_NAME=<runner_name> \
-e GITEA_RUNNER_LABELS=<runner_labels> \
--name my_runner \
-d gitea/act_runner:latest
```
# yml工作流
```yml
name: Blog CI & CD
on:
push:
branches:
- master
env:
# hugo生成site所在路径
REPO_DIR: /usr/local/hugo/blog
# 静态文件服务器代理的路径
DEPLOYED_DIR: /var/www/blog
jobs:
build:
name: Build_blog
runs-on: ubuntu-22.04
steps:
- name: pull
# pull远程仓库
run: |
git -C $REPO_DIR pull
deploy:
name: Deploy blog
runs-on: ubuntu-22.04
needs: Build_blog
steps:
- name: Deploy
# 指定hugo site路径-D 忽略草稿,-d 生成文件放在指定路径下
run: |
hugo -s $REPO_DIR -D -d $DEPLOYED_DIR
```