2021 github action for gh pages
Post
Cancel

github action for gh pages

fatal: could not read Password for ‘https://github.com’: No such device or address。在此期间我试了很多次解决此类问题,否定了有关于网上所说的:git远程仓,账户@密码.git、ssh key等相关原因。没有必要再纠结于此,随后尝试了其他的action。

虽然都是为了push gh-pages而实现的,每个action for gh-page实际提供的键值对也是各有迥异。后来部署成功是因为比对如下的repo的用例说明,发现了历史版本键值对的键参数格式的变更问题。

actions/checkout@v2,这是github官方的一个action,用于clone该仓库的源码到工作流中。如下代码其实说白了,我就做三件事情:

  • 代码导入系统容器
  • yarn install与build doc
  • 上传到gh-page分支
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Deploy GitHub Pages

# 触发条件:在 push 到 master 分支后
on:
  push:
    branches:
      - master

# 任务
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          persist-credentials: false 

      - name: install
        run: yarn install 

      - name: Build
        run:  yarn docs:build

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@4.1.1
        with:
          token: ${{ secrets.ACCESS_TOKEN }}
          branch: gh-pages # The branch the action should deploy to.
          folder: docs/.vuepress/dist # The folder the action should deploy.

persist-credentials: falseactions/checkout对此的说明:

1
2
3
# Whether to configure the token or SSH key with the local git config
# Default: true
persist-credentials: ''

是使用本地git config配置令牌还是SSH密钥,难怪persist-credentials: false之后需要$验证。

这个$一开始也是,让我想了好久。它实际上为GitHub设置中的Settings Developer settings/Personal access tokens的生成令牌。将令牌复制到repo的Actions secrets并命名为ACCESS_TOKEN

This post is licensed under CC BY 4.0 by the author.
载入天数...载入时分秒...