GithubHelp home page GithubHelp logo

yrpang / github-actions-hexo Goto Github PK

View Code? Open in Web Editor NEW
20.0 2.0 11.0 26 KB

A Github action used to automatic generate publish hexo-based blog and clear Cloudflare cache.

License: MIT License

Dockerfile 17.51% Shell 82.49%

github-actions-hexo's Introduction

Github Action for Hexo

The GitHub Actions for automatic generate and deploy hexo-based blog.

Features:

  • Update source files after hexo g

  • Clean CloudFlare cached after deploy(Only support CloudFlare Token. For more you can try Cloudflare Purge Cache)

Usage

Before using this action, please config hexo env locally and install hexo-deployer-git plugin. The official reference documentation of the plugin is https://hexo.io/docs/one-command-deployment#Git

e.g.

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment#Git
deploy:
  type: git
  repo: [email protected]:yrpang/yrpang.github.io.git
  branch: master

Prepare

  • Apply a DEPLOY_KEY for the repository of your GitHub Page

  • (Use Cloudflare Only)Apply a CLOUDFLARE_API_KEY

Example Workflow file

name: Hexo Build and Deploy

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Cache node modules
        uses: actions/cache@v1
        with:
          path: node_modules
          key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}}
      - uses: yrpang/[email protected]
        with:
          deploykey: ${{secrets.DEPLOY_KEY}}
          username: PUBLISHER_USER_NAME
          email: PUBLISHER_EMAIL_ADDRESS

Inputs

Name Type Required Default Description
deploykey secrets Yes The deploy key of your GitHub Page repository
username string 'github-actions[bot]' The publisher's username
email string '41898282+github-actions[bot]@users.noreply.github.com' The publisher's email address
if_keep_commit_history boolean false Whether keep commit history
github_page_repository string When if_keep_commit_history is ture and the GitHub Page repository (branch) is not <actor_username>.github.io, you need to set the other GitHub Page repository (branch) for get the commit history.
github_page_repository_branch string 'master' When if_keep_commit_history is ture and the GitHub Page repository (branch) is not <actor_username>.github.io, you need to set the other GitHub Page repository (branch) for get the commit history.
if_update_files boolean false Whether update the source file after generate
github_token secrets Token for the repo. Can be passed in using ${{ secrets.GITHUB_TOKEN }}
branch string 'master' The branch of the blog source code
if_update_cloudflare boolean false Whether update cloudflare
cloudflare_zone string the cloudflare zone
cloudflare_token secrets Your cloudflare token

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License.

No affiliation with GitHub Inc.

GitHub are registered trademarks of GitHub, Inc. GitHub name used in this project are for identification purposes only. The project is not associated in any way with GitHub Inc. and is not an official solution of GitHub Inc. It was made available in order to facilitate the use of the site GitHub.

github-actions-hexo's People

Contributors

fabiofdsantos avatar maboloshi avatar yrpang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

github-actions-hexo's Issues

关于获取历史提交的讨论

之前我提交的 #5 引入了github_page_repositorygithub_page_repository_branch用于手动设置其他GitHub Page存放项目及分支, 事实上这个信息在hexo的设置文件_config.ymldeploy节已经指定, 如果能自动获取就更好了.

另外, 在sma11black/hexo-action项目中使用sync_deploy_history.js实现自动获取并同步历史提交

Can't deploy to github pages

Hello, I happended to error, such that cannot deploy to github pages.

I use two repositories

  1. ganariya.github.io
  2. ganariya_blog(private)

and ganariya_blog is the hexo repository and deploy to ganariya.github.io.

And I'd like to use github-actions-hexo, so
I make ssh and set public-key in ganariya.github.io and
I set private-key as DEPLOY_KEY in ganariya_blog.

But, actions happens error

2019-12-27T12:40:23.5083253Z ##[group]Run yrpang/github-actions-hexo@master
2019-12-27T12:40:23.5083845Z with:
2019-12-27T12:40:23.5090460Z   deploykey: ***

2019-12-27T12:40:23.5090997Z   username: Ganariya
2019-12-27T12:40:23.5092159Z   email: [email protected]
2019-12-27T12:40:23.5092693Z   if_update_files: false
2019-12-27T12:40:23.5093211Z   branch: master
2019-12-27T12:40:23.5093721Z   if_update_cloudflare: false
2019-12-27T12:40:23.5094231Z ##[endgroup]
2019-12-27T12:40:23.5138153Z ##[command]/usr/bin/docker run --name ee6d39f9bc3dca347fcb1f699254ef090be_ccf700 --label 671ee6 --workdir /github/workspace --rm -e INPUT_DEPLOYKEY -e INPUT_USERNAME -e INPUT_EMAIL -e INPUT_IF_UPDATE_FILES -e INPUT_GITHUB_TOKEN -e INPUT_BRANCH -e INPUT_IF_UPDATE_CLOUDFLARE -e INPUT_CLOUDFLARE_API_KEY -e INPUT_CLOUDFLARE_ZONE -e INPUT_CLOUDFLARE_USERNAME -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/ganariya_blog/ganariya_blog":"/github/workspace" 671ee6:d39f9bc3dca347fcb1f699254ef090be
2019-12-27T12:40:23.8516811Z # github.com:22 SSH-2.0-babeld-778045a0
2019-12-27T12:40:27.8393868Z /usr/local/bin/hexo -> /usr/local/lib/node_modules/hexo-cli/bin/hexo
2019-12-27T12:40:27.8671392Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/hexo-cli/node_modules/fsevents):
2019-12-27T12:40:27.8673090Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-12-27T12:40:27.8678795Z 
2019-12-27T12:40:27.8689553Z + [email protected]
2019-12-27T12:40:27.8690056Z added 82 packages from 356 contributors in 3.421s
2019-12-27T12:40:35.5742560Z 
2019-12-27T12:40:35.5743898Z > [email protected] postinstall /github/workspace/node_modules/ejs
2019-12-27T12:40:35.5744911Z > node ./postinstall.js
2019-12-27T12:40:35.5745370Z 
2019-12-27T12:40:35.6237811Z Thank you for installing �[35mEJS�[0m: built with the �[32mJake�[0m JavaScript build tool (�[32mhttps://jakejs.com/�[0m)
2019-12-27T12:40:35.6239080Z 
2019-12-27T12:40:36.1355735Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/nunjucks/node_modules/fsevents):
2019-12-27T12:40:36.1422650Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-12-27T12:40:36.1432862Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
2019-12-27T12:40:36.1443853Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-12-27T12:40:36.1453324Z 
2019-12-27T12:40:36.1485454Z added 372 packages from 472 contributors and audited 2744 packages in 7.735s
2019-12-27T12:40:36.3534241Z 
2019-12-27T12:40:36.3535087Z 3 packages are looking for funding
2019-12-27T12:40:36.3535579Z   run `npm fund` for details
2019-12-27T12:40:36.3535821Z 
2019-12-27T12:40:36.3541392Z found 0 vulnerabilities
2019-12-27T12:40:36.3541852Z 
2019-12-27T12:40:37.5005101Z INFO  Start processing
2019-12-27T12:40:37.7538298Z INFO  Files loaded in 255 ms
2019-12-27T12:40:38.3423095Z INFO  Generated: index.html
2019-12-27T12:40:38.3453742Z INFO  Generated: archives/index.html
2019-12-27T12:40:38.3491178Z INFO  Generated: fancybox/blank.gif
2019-12-27T12:40:38.3491858Z INFO  Generated: fancybox/jquery.fancybox.css
2019-12-27T12:40:38.3492715Z INFO  Generated: fancybox/jquery.fancybox.js
2019-12-27T12:40:38.3493237Z INFO  Generated: fancybox/jquery.fancybox.pack.js
2019-12-27T12:40:38.3510033Z INFO  Generated: fancybox/fancybox_loading.gif
2019-12-27T12:40:38.3510605Z INFO  Generated: fancybox/[email protected]
2019-12-27T12:40:38.3511151Z INFO  Generated: fancybox/fancybox_sprite.png
2019-12-27T12:40:38.3521925Z INFO  Generated: archives/2019/12/index.html
2019-12-27T12:40:38.3523475Z INFO  Generated: tags/this-is-test/index.html
2019-12-27T12:40:38.3524043Z INFO  Generated: fancybox/fancybox_overlay.png
2019-12-27T12:40:38.3524601Z INFO  Generated: archives/2019/index.html
2019-12-27T12:40:38.3545440Z INFO  Generated: js/script.js
2019-12-27T12:40:38.3546520Z INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.css
2019-12-27T12:40:38.3547088Z INFO  Generated: fancybox/[email protected]
2019-12-27T12:40:38.3547797Z INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.js
2019-12-27T12:40:38.3548534Z INFO  Generated: fancybox/helpers/jquery.fancybox-media.js
2019-12-27T12:40:38.3549258Z INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.css
2019-12-27T12:40:38.3549992Z INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.js
2019-12-27T12:40:38.3556413Z INFO  Generated: css/fonts/FontAwesome.otf
2019-12-27T12:40:38.3562728Z INFO  Generated: css/fonts/fontawesome-webfont.svg
2019-12-27T12:40:38.3566874Z INFO  Generated: css/fonts/fontawesome-webfont.eot
2019-12-27T12:40:38.3571275Z INFO  Generated: css/fonts/fontawesome-webfont.woff
2019-12-27T12:40:38.3575593Z INFO  Generated: fancybox/helpers/fancybox_buttons.png
2019-12-27T12:40:38.3580630Z INFO  Generated: css/style.css
2019-12-27T12:40:38.3585134Z INFO  Generated: 2019/12/27/nyann/index.html
2019-12-27T12:40:38.3589397Z INFO  Generated: css/images/banner.jpg
2019-12-27T12:40:38.3595616Z INFO  Generated: 2019/12/27/sample-page/index.html
2019-12-27T12:40:38.3596397Z INFO  Generated: 2019/12/27/test-page/index.html
2019-12-27T12:40:38.3603455Z INFO  Generated: css/fonts/fontawesome-webfont.ttf
2019-12-27T12:40:38.3604256Z INFO  Generated: 2019/12/27/hello-world/index.html
2019-12-27T12:40:38.3611486Z INFO  32 files generated in 607 ms
2019-12-27T12:40:39.4254425Z INFO  Deploying: git
2019-12-27T12:40:39.4323274Z INFO  Setting up Git deployment...
2019-12-27T12:40:39.4424020Z Initialized empty Git repository in /github/workspace/.deploy_git/.git/
2019-12-27T12:40:39.4550148Z [master (root-commit) 2afa7ee] First commit
2019-12-27T12:40:39.4554373Z  1 file changed, 0 insertions(+), 0 deletions(-)
2019-12-27T12:40:39.4554967Z  create mode 100644 placeholder
2019-12-27T12:40:39.4564383Z INFO  Clearing .deploy_git folder...
2019-12-27T12:40:39.4589249Z INFO  Copying files from public folder...
2019-12-27T12:40:39.4749459Z INFO  Copying files from extend dirs...
2019-12-27T12:40:39.5326337Z [master 0a99d87] Site updated: 2019-12-27 12:40:39
2019-12-27T12:40:39.5353288Z  33 files changed, 7134 insertions(+)
2019-12-27T12:40:39.5354297Z  create mode 100644 2019/12/27/hello-world/index.html
2019-12-27T12:40:39.5354878Z  create mode 100644 2019/12/27/nyann/index.html
2019-12-27T12:40:39.5355665Z  create mode 100644 2019/12/27/sample-page/index.html
2019-12-27T12:40:39.5356571Z  create mode 100644 2019/12/27/test-page/index.html
2019-12-27T12:40:39.5357114Z  create mode 100644 archives/2019/12/index.html
2019-12-27T12:40:39.5357648Z  create mode 100644 archives/2019/index.html
2019-12-27T12:40:39.5358165Z  create mode 100644 archives/index.html
2019-12-27T12:40:39.5358689Z  create mode 100644 css/fonts/FontAwesome.otf
2019-12-27T12:40:39.5359583Z  create mode 100644 css/fonts/fontawesome-webfont.eot
2019-12-27T12:40:39.5360356Z  create mode 100644 css/fonts/fontawesome-webfont.svg
2019-12-27T12:40:39.5361118Z  create mode 100644 css/fonts/fontawesome-webfont.ttf
2019-12-27T12:40:39.5361857Z  create mode 100644 css/fonts/fontawesome-webfont.woff
2019-12-27T12:40:39.5362735Z  create mode 100644 css/images/banner.jpg
2019-12-27T12:40:39.5363273Z  create mode 100644 css/style.css
2019-12-27T12:40:39.5363766Z  create mode 100644 fancybox/blank.gif
2019-12-27T12:40:39.5364500Z  create mode 100644 fancybox/fancybox_loading.gif
2019-12-27T12:40:39.5365089Z  create mode 100644 fancybox/[email protected]
2019-12-27T12:40:39.5365722Z  create mode 100644 fancybox/fancybox_overlay.png
2019-12-27T12:40:39.5366270Z  create mode 100644 fancybox/fancybox_sprite.png
2019-12-27T12:40:39.5366807Z  create mode 100644 fancybox/[email protected]
2019-12-27T12:40:39.5367368Z  create mode 100644 fancybox/helpers/fancybox_buttons.png
2019-12-27T12:40:39.5368253Z  create mode 100644 fancybox/helpers/jquery.fancybox-buttons.css
2019-12-27T12:40:39.5369258Z  create mode 100644 fancybox/helpers/jquery.fancybox-buttons.js
2019-12-27T12:40:39.5370059Z  create mode 100644 fancybox/helpers/jquery.fancybox-media.js
2019-12-27T12:40:39.5371041Z  create mode 100644 fancybox/helpers/jquery.fancybox-thumbs.css
2019-12-27T12:40:39.5371804Z  create mode 100644 fancybox/helpers/jquery.fancybox-thumbs.js
2019-12-27T12:40:39.5372715Z  create mode 100644 fancybox/jquery.fancybox.css
2019-12-27T12:40:39.5373277Z  create mode 100644 fancybox/jquery.fancybox.js
2019-12-27T12:40:39.5373867Z  create mode 100644 fancybox/jquery.fancybox.pack.js
2019-12-27T12:40:39.5374419Z  create mode 100644 index.html
2019-12-27T12:40:39.5374931Z  create mode 100644 js/script.js
2019-12-27T12:40:39.5375573Z  delete mode 100644 placeholder
2019-12-27T12:40:39.5376314Z  create mode 100644 tags/this-is-test/index.html
2019-12-27T12:40:39.5757979Z fatal: could not read Username for 'https://github.com': No such device or address
2019-12-27T12:40:39.5780211Z FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
2019-12-27T12:40:39.5781413Z Error: Spawn failed
2019-12-27T12:40:39.5782332Z     at ChildProcess.<anonymous> (/github/workspace/node_modules/hexo-util/lib/spawn.js:51:21)
2019-12-27T12:40:39.5784993Z     at ChildProcess.emit (events.js:305:20)
2019-12-27T12:40:39.5785604Z     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
2019-12-27T12:40:40.9099113Z ##[error]Docker run failed with exit code 2
2019-12-27T12:40:40.9130840Z Cleaning up orphan processes

And my main.yml is

name: Hexo Build and Deploy

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Cache node modules
        uses: actions/cache@v1
        with:
          path: node_modules
          key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}}
      - uses: yrpang/github-actions-hexo@master
        with:
          deploykey: ${{secrets.DEPLOY_KEY}}
          username: "Ganariya"
          email: "[email protected]"

I would you to give me some advice.

Sorry, for bad English, thank you.

✖ Error: Command failed: /bin/sh -c autoreconf -ivf

这是日志:

/usr/local/bin/hexo -> /usr/local/lib/node_modules/hexo-cli/bin/hexo
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/hexo-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ [email protected]
added 61 packages from 315 contributors in 3.041s

> [email protected] postinstall /github/workspace/node_modules/babel-polyfill/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> [email protected] postinstall /github/workspace/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> [email protected] postinstall /github/workspace/node_modules/ejs
> node ./postinstall.js


> [email protected] postinstall /github/workspace/node_modules/gifsicle
> node lib/install.js


  ⚠ spawn /github/workspace/node_modules/gifsicle/vendor/gifsicle ENOENT
  ⚠ gifsicle pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c autoreconf -ivf
/bin/sh: autoreconf: not found

    at /github/workspace/node_modules/execa/index.js:231:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/hexo-tag-aplayer/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/hexo-blog-encrypt/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /github/home/.npm/_logs/2020-08-10T01_40_40_412Z-debug.log

这是 deploy.yml :

name: 自动部署 Hexo

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x]

    steps:
      - name: 开始运行
        uses: actions/checkout@v1

      - name: 缓存
        uses: actions/cache@v1
        id: cache-dependencies
        with:
          path: node_modules
          key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}}

#      - name: 安装系统依赖
#        run: |
#          sudo apt-get install autoconf

      - name: 部署准备
        run: |
          git clone https://${{secrets.GH_TOKEN}}@github.com/RebornQ/rebornQ.github.io.git .deploy_git
          cp ./_config.yml ./_config_backup.yml
          sed -i 's/[email protected]:/https:\/\/${{secrets.GH_TOKEN}}@github.com\//g' ./_config.yml
      - name: 部署博客
        uses: yrpang/github-actions-hexo@master
        with:
          github_token: ${{secrets.GH_TOKEN}}
          username: ${{secrets.GIT_NAME}}
          email: ${{secrets.GIT_EMAIL}}
      - name: 清理
        run: |
          mv ./_config_backup.yml ./_config.yml

看起来是 dockerflie 的问题,查了一下资料,根据 这个链接 里面说的,可能需要在 dockerfile 里加上这一句:

RUN apk add --update autoreconf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.