Skip to content

13. gitea runner配置 ​

运行端容器 ​

  • gitea/act_runner:0.6.1
  • 镜像基于alpine
  • 示例基于vitepress,理论上适用任何web前端(yarn pnpm可以构建的)
# 切换为科大(USTC)Alpine 镜像源
echo "https://mirrors.ustc.edu.cn/alpine/v3.23/main" > /etc/apk/repositories
echo "https://mirrors.ustc.edu.cn/alpine/v3.23/community" >> /etc/apk/repositories

# 更新源并安装 nodejs、npm、rsync、openssh-client
apk update && apk add --no-cache nodejs npm rsync openssh-client
# 切换npm淘宝源
npm config set registry https://registry.npmmirror.com

# 全局安装 pnpm 和 yarn
npm install -g pnpm yarn
# 产生ssh key
ssh-keygen -t ed25519
# 添加到远程主机
ssh-copy-id user@remote-ip
# ssh登陆一次,保存远程主机的fingerprint
ssh user@remote-ip

yaml示例 ​

  • repo/.gitea/workflows/任意名字.yaml
name: Node.js CI with pnpm
run-name: ${{ gitea.actor }} is building the project with pnpm 🚀

on:
  push:
    branches: [ "main", "master", "*" ]

jobs:
  build:
    runs-on: dpanel

    steps:
      - name: Checkout code manually
        run: |
          git clone http://${{ gitea.token }}@192.168.0.5:3000/${{ gitea.repository }}.git .
          git checkout ${{ gitea.sha }}
      - name: Install dependencies
        run: yarn

      - name: Run Deploy
        run: yarn deploy

      - run: echo "🍏 Build job's status is ${{ job.status }}."

基于 Vitepress.