2024年11月29日Memo在自部署的 Gitea 中,使用 Actions 和 [actions/checkout@v4](https://github.com/actions/checkout/tree/v4/) 拉取子模块GitGitea先准备一个机器人账户,专门用来在 actions 中对 gitea 进行访问。如果不在意安全性或做功能验证,可以把自己的账户当作这个机器人账户使用。 首先通过 ssh-keygen -t ed25519 -C "your_email@gitea.example.com" -f ~/Downloads/ssh_key 生成一对公私钥。 = 私钥是 ssh-key,将其添加到 Actions 密钥中,可以将密钥命名为 SSH-KEY; 公钥保存到机器人账户的 SSH 密钥中。 然后,通过 ssh-keyscan gitea.example.com 获取 Gitea 实例的 SSH 主机ed25519 的指纹。一行一个,找到类似 gitea.example.com ssh-ed25519 AAAAC3NzaC…… 这样的行。这行就是 ssh-known-hosts,可以直接在工作流配置文件里硬编码。 接下来,将 actions/checkout@v4 步骤改成下面这样: - name: Git Setup run: | mkdir -p ~/.ssh echo 'Host git.ivanli.cc ' >> ~/.ssh/config echo ' HostName git.ivanli.cc' >> ~/.ssh/config echo ' Port 7018' >> ~/.ssh/config cat ~/.ssh/config - uses: actions/checkout@v4 with: submodules: true ssh-key: ${{ secrets.SSH_KEY }} ssh-known-hosts: gitea.example.com ssh-ed25519 AAAAC3NzaC…… ssh-user: gitea 然后大功告成。
在自部署的 Gitea 中,使用 Actions 和 [actions/checkout@v4](https://github.com/actions/checkout/tree/v4/) 拉取子模块
先准备一个机器人账户,专门用来在 actions 中对 gitea 进行访问。如果不在意安全性或做功能验证,可以把自己的账户当作这个机器人账户使用。
首先通过
ssh-keygen -t ed25519 -C "your_email@gitea.example.com" -f ~/Downloads/ssh_key生成一对公私钥。= 私钥是
ssh-key,将其添加到 Actions 密钥中,可以将密钥命名为SSH-KEY;然后,通过
ssh-keyscan gitea.example.com获取 Gitea 实例的 SSH 主机ed25519的指纹。一行一个,找到类似gitea.example.com ssh-ed25519 AAAAC3NzaC……这样的行。这行就是ssh-known-hosts,可以直接在工作流配置文件里硬编码。接下来,将
actions/checkout@v4步骤改成下面这样:- name: Git Setup run: | mkdir -p ~/.ssh echo 'Host git.ivanli.cc ' >> ~/.ssh/config echo ' HostName git.ivanli.cc' >> ~/.ssh/config echo ' Port 7018' >> ~/.ssh/config cat ~/.ssh/config - uses: actions/checkout@v4 with: submodules: true ssh-key: ${{ secrets.SSH_KEY }} ssh-known-hosts: gitea.example.com ssh-ed25519 AAAAC3NzaC…… ssh-user: gitea然后大功告成。