GithubAction-Deploy

4990 ワード

GithubAction-Deploy
github
hexo
action
github actionによる導入の自動化
GitHub repository格納元ファイルを作成repo設定インタフェースにSecretsを追加(ローカルに一対の公開鍵ssh-keygenを生成し、ここに秘密鍵を記入し、ACTION_DEPLOY_KEY(任意に命名できるが、Actionsの設定$に対応する)GitHub pagesを格納するrepo設定Deploy keys生成したばかりの公開鍵としてルートディレクトリの下にGitHub Actions workflowファイルを作成する
name: Build and Update Note.junyangz.com for github pages
on: push
jobs:
  build:
    runs-on: macOS-latest
    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js 10.x
        uses: actions/setup-node@v1
        with:
          node-version: "10.x"
      - name: Setup Hexo env
        env:
          ACTION_DEPLOY_KEY: ${{ secrets.ACTION_DEPLOY_KEY }}
        run: |
          # set up private key for deploy
          mkdir -p ~/.ssh/
          echo "$ACTION_DEPLOY_KEY" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          # set git infomation
          git config --global user.name 'Junyangz'
          git config --global user.email '[email protected]'
          # install dependencies
          npm i -g hexo-cli
          npm i
      - name: Deploy
        run: |
          # generate and depoly
          hexo g -d

リファレンスリンク
  • GitHub Actions配備Hexoブログ
  • Github ActionsによるHexo
  • の自動配備