1 Star 0 Fork 0

york / gitee-pages-action

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

lint status Mirror status PRs Welcome users FOSSA Status
release github gitee faq

Gitee Pages Action

由于 Gitee Pages 的访问速度很快,很多朋友会选择 Gitee Pages 部署项目(如:个人博客、开源项目国内镜像站点)。但是它不像 GitHub Pages 那样,一提交代码就能自动更新 Pages,因为 Gitee 的自动部署属于 Gitee Pages Pro 的服务。

为了实现 Gitee Pages 的自动部署,我开发了 Gitee Pages Action ,只需要在 GitHub 项目的 Settings 页面下配置 keys,然后在 .github/workflows/ 下创建一个工作流,引入一些配置参数即可。欢迎体验,若有使用上的问题,也欢迎随时在 Issues 反馈。

注:首次需要手动登录 Gitee ,点击“启动”进行 Gitee Pages 服务的部署。

入参

参数 描述 是否必传 默认值 示例
gitee-username Gitee 用户名 - yanglbme
gitee-password Gitee 密码 - ${{ secrets.GITEE_PASSWORD }}
gitee-repo Gitee 仓库(严格区分大小写) - doocs/advanced-java
branch 要部署的分支(分支必须存在) master main
directory 要部署的分支上的目录 src
https 是否强制使用 HTTPS true false

示例

以下是一个完整示例。

在你的 GitHub 仓库 .github/workflows/ 文件夹下创建一个 .yml 文件,如 sync.yml,内容如下:

name: Sync

on: page_build

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Sync to Gitee
        uses: wearerequired/git-mirror-action@master
        env:
          # 注意在 Settings->Secrets 配置 GITEE_RSA_PRIVATE_KEY
          SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
        with:
          # 注意替换为你的 GitHub 源仓库地址
          source-repo: git@github.com:doocs/advanced-java.git
          # 注意替换为你的 Gitee 目标仓库地址
          destination-repo: git@gitee.com:Doocs/advanced-java.git

      - name: Build Gitee Pages
        uses: yanglbme/gitee-pages-action@main
        with:
          # 注意替换为你的 Gitee 用户名
          gitee-username: yanglbme
          # 注意在 Settings->Secrets 配置 GITEE_PASSWORD
          gitee-password: ${{ secrets.GITEE_PASSWORD }}
          # 注意替换为你的 Gitee 仓库,仓库名严格区分大小写,请准确填写,否则会出错
          gitee-repo: doocs/advanced-java
          # 要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在)
          branch: main

先使用 wearerequired/git-mirror-action 将 GitHub 仓库同步到 Gitee 仓库,再使用 yanglbme/gitee-pages-action 实现 Gitee Pages 的自动部署。

密钥的配置步骤如下(可展开看示例图)

1. 在命令行终端或 Git Bash 使用命令 ssh-keygen -t rsa -C "youremail@example.com" 生成 SSH Key,注意替换为自己的邮箱。生成的 id_rsa 是私钥,id_rsa.pub 是公钥。 gen_ssh_key
2. 在 GitHub 项目的「​Settings -> Secrets」路径下配置好命名为 GITEE_RSA_PRIVATE_KEYGITEE_PASSWORD 的两个密钥。其中:GITEE_RSA_PRIVATE_KEY 存放 id_rsa 私钥;GITEE_PASSWORD 存放 Gitee 帐号的密码。 add_secrets
3. 在 GitHub 的个人设置页面「Settings -> SSH and GPG keys」​ 配置 SSH 公钥(即:id_rsa.pub),命名随意。 add_ssh_key_github
4. 在 Gitee 的个人设置页面「安全设置 -> SSH 公钥」​ 配置 SSH 公钥(即:id_rsa.pub),命名随意。 add_ssh_key_gitee

如果一切配置正常,并成功触发 Gitee Pages Action ,我们会在 Gitee 公众号收到一条登录通知。这是 Gitee Pages Action 程序帮我们登录到 Gitee 官网,并为我们点击了项目的部署按钮。

错误及解决方案

# 错误 解决方案
1 Error: Wrong username or password, login failed . 帐号或密码错误,请检查参数 gitee-usernamegitee-password是否准确配置。
2 Error: Need captcha validation, please visit https://gitee.com/login, login to validate your account. 需要图片验证码校验。可以手动登录 Gitee 官方,校验验证码。
3 Error: Need phone captcha validation, please follow gitee wechat subscription and bind your account. 需要短信验证码校验。可以关注 Gitee 微信公众号,并绑定 Gitee 帐号,接收登录提示。#6
4 Error: Do not deploy frequently, try again one minute later. 短期内频繁部署 Gitee Pages 导致,可以稍后再触发自动部署。
5 Error: Deploy error occurred, please check your input gitee-repo. gitee-repo 参数格式如:doocs/advanced-java,并且严格区分大小写,请准确填写。#10
6 Error: Unknown error occurred in login method, resp: ... 登录出现未知错误,请在 issues 区反馈。
7 Error: Rebuild page error, status code: xxx 更新 Pages 时状态码异常,请尝试再次触发 Action 执行。
8 Error: HTTPSConnectionPool(host='gitee.com', port=443): Read timed out. (read timeout=6) 网络请求出错,请尝试 Re-run jobs 。#27
9 git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists..
SSH 公私钥配置有问题,请参照上文提及的密钥配置步骤进行相应配置。#29
... ... ...

注:

  1. branch 参数默认是 master,如果你是部署在 gh-pages(或者 main) 分支等等,务必指定 branch: gh-pages(或者 branch: main)。
  2. branch 对应的分支,必须在仓库中实际存在,请不要随意(不)指定分支,否则可能导致 Gitee Pages 站点出现 404 无法访问的情况。
  3. 示例中触发 Action 执行的事件设置为 page_build,你也可以根据实际情况指定为其它的触发事件。请参考 Events that trigger workflows

谁在使用


蚂蚁金服 - 数据可视化

Doocs 技术社区

有赞

License

FOSSA Status

The MIT License (MIT) Copyright © 2020 <copyright Yang Libin> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

🤖 无须人为干预,自动部署 Gitee Pages 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/Mikeywk/gitee-pages-action.git
git@gitee.com:Mikeywk/gitee-pages-action.git
Mikeywk
gitee-pages-action
gitee-pages-action
main

搜索帮助