原创

github action部署问题记录

1、现象

Run peaceiris/actions-gh-pages@v3
[INFO] Usage https://github.com/peaceiris/actions-gh-pages#readme
Dump inputs
Setup auth token
  [INFO] setup SSH deploy key
  /usr/bin/chmod 700 /home/runner/.ssh
  [INFO] wrote /home/runner/.ssh/known_hosts
  /usr/bin/chmod 600 /home/runner/.ssh/known_hosts
  [INFO] wrote /home/runner/.ssh/github
  /usr/bin/chmod 600 /home/runner/.ssh/github
  [INFO] wrote /home/runner/.ssh/config
  /usr/bin/chmod 600 /home/runner/.ssh/config
  /usr/bin/ssh-add /home/runner/.ssh/github
  Error loading key "/home/runner/.ssh/github": invalid format
  Error: Action failed with "The process '/usr/bin/ssh-add' failed with exit code 1"

2、当前job的配置文件

name: GitHubPages

on:
  push:
    branches:
      - master  # Set a branch to deploy

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          # hugo-version: '${{ steps.hugo-version.outputs.HUGO_VERSION }}'
          hugo-version: '0.92.2'
          extended: true

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_branch: gh-pages
          publish_dir: ./public
          cname: www.pg.run

3、调整后的

name: github pages

on:
  push:
    branches:
      - master  # Set a branch to deploy

jobs:
  deploy:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: false  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: 'latest'
          # extended: true

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public
          cname: www.gzcx.net

4、总结

解决问题的关键步骤是将deploy的key换成了token.

  • key是私钥
  • token是新建立出来的访问的密钥
正文到此结束
本文目录