sma11black / hexo-action

Hexo CI/CD Action for automating deployment.
MIT License
162 stars 74 forks source link

Error: Cannot find module 'hexo' #8

Closed wilkice closed 4 years ago

wilkice commented 4 years ago

my config yaml

name: deploy to github.io

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:

  build:

    runs-on: ubuntu-latest

    steps:

    - uses: actions/checkout@v2

    - name: Hexo Action
      uses: sma11black/hexo-action@v1.0.2
      with:

        deploy_key: ${{ secrets.DEPLOY_KEY }}

And there are only one file index.md in my hexo repo.

Error logs when building

2020-07-17T09:36:40.5214005Z ##[section]Starting: Request a runner to run this job
2020-07-17T09:36:41.0560059Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'ubuntu-latest'
2020-07-17T09:36:41.0560174Z Can't find any online and idle self-hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-latest'
2020-07-17T09:36:41.0560345Z Found online and idle hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-latest'
2020-07-17T09:36:41.3477984Z ##[section]Finishing: Request a runner to run this job
2020-07-17T09:36:49.5100720Z Current runner version: '2.267.1'
2020-07-17T09:36:49.5207756Z ##[group]Operating System
2020-07-17T09:36:49.5209211Z Ubuntu
2020-07-17T09:36:49.5209916Z 18.04.4
2020-07-17T09:36:49.5210613Z LTS
2020-07-17T09:36:49.5211322Z ##[endgroup]
2020-07-17T09:36:49.5212036Z ##[group]Virtual Environment
2020-07-17T09:36:49.5212799Z Environment: ubuntu-18.04
2020-07-17T09:36:49.5213501Z Version: 20200709.0
2020-07-17T09:36:49.5214423Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu18/20200709.0/images/linux/Ubuntu1804-README.md
2020-07-17T09:36:49.5215308Z ##[endgroup]
2020-07-17T09:36:49.5217142Z Prepare workflow directory
2020-07-17T09:36:49.5670522Z Prepare all required actions
2020-07-17T09:36:49.5691354Z Download action repository 'actions/checkout@v2'
2020-07-17T09:36:51.3940355Z Download action repository 'sma11black/hexo-action@v1.0.2'
2020-07-17T09:36:51.7278653Z Build container for action use: '/home/runner/work/_actions/sma11black/hexo-action/v1.0.2/Dockerfile'.
2020-07-17T09:36:51.7349862Z ##[command]/usr/bin/docker build -t 87c201:2740fc213fac4f0fa9ac20fc03684947 -f "/home/runner/work/_actions/sma11black/hexo-action/v1.0.2/Dockerfile" "/home/runner/work/_actions/sma11black/hexo-action/v1.0.2"
2020-07-17T09:36:52.5148192Z Sending build context to Docker daemon  18.43kB
2020-07-17T09:36:52.5151105Z 
2020-07-17T09:36:52.5703256Z Step 1/9 : FROM node:13-alpine
2020-07-17T09:36:52.7163006Z 13-alpine: Pulling from library/node
2020-07-17T09:36:52.7613952Z cbdbe7a5bc2a: Already exists
2020-07-17T09:36:52.7689304Z 780514bed1ad: Pulling fs layer
2020-07-17T09:36:52.7692407Z 5d74fb112a7d: Pulling fs layer
2020-07-17T09:36:52.7692800Z 4b9536424fa1: Pulling fs layer
2020-07-17T09:36:52.8384857Z 4b9536424fa1: Verifying Checksum
2020-07-17T09:36:52.8388601Z 4b9536424fa1: Download complete
2020-07-17T09:36:52.8835340Z 5d74fb112a7d: Verifying Checksum
2020-07-17T09:36:52.8839607Z 5d74fb112a7d: Download complete
2020-07-17T09:36:53.1267965Z 780514bed1ad: Verifying Checksum
2020-07-17T09:36:53.1268727Z 780514bed1ad: Download complete
2020-07-17T09:36:54.8058267Z 780514bed1ad: Pull complete
2020-07-17T09:36:54.9401894Z 5d74fb112a7d: Pull complete
2020-07-17T09:36:55.0010310Z 4b9536424fa1: Pull complete
2020-07-17T09:36:55.0032677Z Digest: sha256:527c70f74817f6f6b5853588c28de33459178ab72421f1fb7b63a281ab670258
2020-07-17T09:36:55.0088304Z Status: Downloaded newer image for node:13-alpine
2020-07-17T09:36:55.0097635Z  ---> 8216bf4583a5
2020-07-17T09:36:55.0098104Z Step 2/9 : LABEL version="1.0.0"
2020-07-17T09:36:56.8628166Z  ---> Running in 151ce95dece3
2020-07-17T09:36:57.2432505Z Removing intermediate container 151ce95dece3
2020-07-17T09:36:57.2433107Z  ---> 8054788df20d
2020-07-17T09:36:57.2434241Z Step 3/9 : LABEL repository="https://github.com/sma11black/hexo-action"
2020-07-17T09:36:57.2704252Z  ---> Running in f02389ed6db3
2020-07-17T09:36:58.0234599Z Removing intermediate container f02389ed6db3
2020-07-17T09:36:58.0235098Z  ---> 5ecf1cd47ad3
2020-07-17T09:36:58.0236172Z Step 4/9 : LABEL homepage="https://sma11black.github.io"
2020-07-17T09:36:58.0454697Z  ---> Running in f2a7d7d69b29
2020-07-17T09:36:59.0191924Z Removing intermediate container f2a7d7d69b29
2020-07-17T09:36:59.0192453Z  ---> 2666f3ea9e33
2020-07-17T09:36:59.0284950Z Step 5/9 : LABEL maintainer="sma11black <smallblack@outlook.com>"
2020-07-17T09:36:59.0504287Z  ---> Running in 7ddb0ac43f04
2020-07-17T09:37:00.0228253Z Removing intermediate container 7ddb0ac43f04
2020-07-17T09:37:00.0228792Z  ---> d1af8793e9d5
2020-07-17T09:37:00.0229446Z Step 6/9 : COPY entrypoint.sh /entrypoint.sh
2020-07-17T09:37:01.0218975Z  ---> 6b85f838b1e5
2020-07-17T09:37:01.0219499Z Step 7/9 : COPY sync_deploy_history.js /sync_deploy_history.js
2020-07-17T09:37:02.0197548Z  ---> 408bccbaaa01
2020-07-17T09:37:02.0207530Z Step 8/9 : RUN apk add --no-cache git openssh > /dev/null ;     chmod +x /entrypoint.sh
2020-07-17T09:37:02.0463778Z  ---> Running in c5c6f67f0161
2020-07-17T09:37:04.8292111Z Removing intermediate container c5c6f67f0161
2020-07-17T09:37:04.8292842Z  ---> 3f3214d7e57d
2020-07-17T09:37:04.8293216Z Step 9/9 : ENTRYPOINT ["/entrypoint.sh"]
2020-07-17T09:37:04.8495709Z  ---> Running in aa8444c9d472
2020-07-17T09:37:05.2274146Z Removing intermediate container aa8444c9d472
2020-07-17T09:37:05.2309427Z  ---> f44bf36e1f24
2020-07-17T09:37:05.2309783Z Successfully built f44bf36e1f24
2020-07-17T09:37:05.2310130Z Successfully tagged 87c201:2740fc213fac4f0fa9ac20fc03684947
2020-07-17T09:37:05.2496940Z ##[group]Run actions/checkout@v2
2020-07-17T09:37:05.2497617Z with:
2020-07-17T09:37:05.2498184Z   repository: wilkice/blog
2020-07-17T09:37:05.2498830Z   token: ***
2020-07-17T09:37:05.2499289Z   ssh-strict: true
2020-07-17T09:37:05.2499746Z   persist-credentials: true
2020-07-17T09:37:05.2500199Z   clean: true
2020-07-17T09:37:05.2501292Z   fetch-depth: 1
2020-07-17T09:37:05.2501831Z   lfs: false
2020-07-17T09:37:05.2502428Z   submodules: false
2020-07-17T09:37:05.2502865Z ##[endgroup]
2020-07-17T09:37:05.7002923Z Syncing repository: wilkice/blog
2020-07-17T09:37:05.7003564Z ##[group]Getting Git version info
2020-07-17T09:37:05.7004618Z Working directory is '/home/runner/work/blog/blog'
2020-07-17T09:37:05.7005095Z [command]/usr/bin/git version
2020-07-17T09:37:05.7098017Z git version 2.27.0
2020-07-17T09:37:05.7131307Z ##[endgroup]
2020-07-17T09:37:05.7140954Z Deleting the contents of '/home/runner/work/blog/blog'
2020-07-17T09:37:05.7145553Z ##[group]Initializing the repository
2020-07-17T09:37:05.7149848Z [command]/usr/bin/git init /home/runner/work/blog/blog
2020-07-17T09:37:05.7235218Z Initialized empty Git repository in /home/runner/work/blog/blog/.git/
2020-07-17T09:37:05.7247598Z [command]/usr/bin/git remote add origin https://github.com/wilkice/blog
2020-07-17T09:37:05.7291787Z ##[endgroup]
2020-07-17T09:37:05.7292598Z ##[group]Disabling automatic garbage collection
2020-07-17T09:37:05.7297204Z [command]/usr/bin/git config --local gc.auto 0
2020-07-17T09:37:05.7332774Z ##[endgroup]
2020-07-17T09:37:05.7338120Z ##[group]Setting up auth
2020-07-17T09:37:05.7346977Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2020-07-17T09:37:05.7387576Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2020-07-17T09:37:05.7858679Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2020-07-17T09:37:05.7921740Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2020-07-17T09:37:05.8210896Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2020-07-17T09:37:05.8270998Z ##[endgroup]
2020-07-17T09:37:05.8272110Z ##[group]Fetching the repository
2020-07-17T09:37:05.8280565Z [command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +bd2a3095a43d13a70fcae9b83ea184413692668e:refs/remotes/origin/master
2020-07-17T09:37:06.1647369Z remote: Enumerating objects: 5, done.        
2020-07-17T09:37:06.1662977Z remote: Counting objects:  20% (1/5)        
2020-07-17T09:37:06.1663989Z remote: Counting objects:  40% (2/5)        
2020-07-17T09:37:06.1664715Z remote: Counting objects:  60% (3/5)        
2020-07-17T09:37:06.1665448Z remote: Counting objects:  80% (4/5)        
2020-07-17T09:37:06.1666204Z remote: Counting objects: 100% (5/5)        
2020-07-17T09:37:06.1666979Z remote: Counting objects: 100% (5/5), done.        
2020-07-17T09:37:06.1667688Z remote: Compressing objects:  50% (1/2)        
2020-07-17T09:37:06.1668842Z remote: Compressing objects: 100% (2/2)        
2020-07-17T09:37:06.1669557Z remote: Compressing objects: 100% (2/2), done.        
2020-07-17T09:37:06.1677203Z remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0        
2020-07-17T09:37:06.2479967Z From https://github.com/wilkice/blog
2020-07-17T09:37:06.2481509Z  * [new ref]         bd2a3095a43d13a70fcae9b83ea184413692668e -> origin/master
2020-07-17T09:37:06.2524626Z ##[endgroup]
2020-07-17T09:37:06.2525237Z ##[group]Determining the checkout info
2020-07-17T09:37:06.2525750Z ##[endgroup]
2020-07-17T09:37:06.2526244Z ##[group]Checking out the ref
2020-07-17T09:37:06.2527382Z [command]/usr/bin/git checkout --progress --force -B master refs/remotes/origin/master
2020-07-17T09:37:06.2604073Z Reset branch 'master'
2020-07-17T09:37:06.2614114Z Branch 'master' set up to track remote branch 'master' from 'origin'.
2020-07-17T09:37:06.2614772Z ##[endgroup]
2020-07-17T09:37:06.2621178Z [command]/usr/bin/git log -1
2020-07-17T09:37:06.2663266Z commit bd2a3095a43d13a70fcae9b83ea184413692668e
2020-07-17T09:37:06.2687702Z Author: darcy <yanjiabinchn@gmail.com>
2020-07-17T09:37:06.2688158Z Date:   Fri Jul 17 17:36:28 2020 +0800
2020-07-17T09:37:06.2688414Z 
2020-07-17T09:37:06.2688814Z     add hexo github actions
2020-07-17T09:37:06.2787036Z ##[group]Run sma11black/hexo-action@v1.0.2
2020-07-17T09:37:06.2787458Z with:
2020-07-17T09:37:06.2789901Z   deploy_key: ***
2020-07-17T09:37:06.2790256Z   user_name: github-actions[bot]
2020-07-17T09:37:06.2790617Z   user_email: 41898282+github-actions[bot]@users.noreply.github.com
2020-07-17T09:37:06.2791018Z ##[endgroup]
2020-07-17T09:37:06.2830433Z ##[command]/usr/bin/docker run --name c2012740fc213fac4f0fa9ac20fc03684947_c7119d --label 87c201 --workdir /github/workspace --rm -e INPUT_DEPLOY_KEY -e INPUT_USER_NAME -e INPUT_USER_EMAIL -e INPUT_COMMIT_MSG -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -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 ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=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/blog/blog":"/github/workspace" 87c201:2740fc213fac4f0fa9ac20fc03684947  "github-actions[bot]" "41898282+github-actions[bot]@users.noreply.github.com" "***" ""
2020-07-17T09:37:07.0073607Z # github.com:22 SSH-2.0-babeld-9389d978
2020-07-17T09:37:08.9052438Z npm WARN deprecated hexo-bunyan@2.0.0: Please see https://github.com/hexojs/hexo-bunyan/issues/17
2020-07-17T09:37:11.3465873Z /usr/local/bin/hexo -> /usr/local/lib/node_modules/hexo-cli/bin/hexo
2020-07-17T09:37:11.3852675Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/hexo-cli/node_modules/chokidar/node_modules/fsevents):
2020-07-17T09:37:11.3853436Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2020-07-17T09:37:11.3853822Z 
2020-07-17T09:37:11.3862187Z + hexo-cli@3.1.0
2020-07-17T09:37:11.3862607Z added 81 packages from 322 contributors in 3.836s
2020-07-17T09:37:15.1827664Z npm WARN saveError ENOENT: no such file or directory, open '/github/workspace/package.json'
2020-07-17T09:37:15.2001127Z npm notice created a lockfile as package-lock.json. You should commit this file.
2020-07-17T09:37:15.2032971Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents):
2020-07-17T09:37:15.2033680Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2020-07-17T09:37:15.2034607Z npm WARN enoent ENOENT: no such file or directory, open '/github/workspace/package.json'
2020-07-17T09:37:15.2035045Z npm WARN workspace No description
2020-07-17T09:37:15.2035409Z npm WARN workspace No repository field.
2020-07-17T09:37:15.2035757Z npm WARN workspace No README data
2020-07-17T09:37:15.2036304Z npm WARN workspace No license field.
2020-07-17T09:37:15.2036494Z 
2020-07-17T09:37:15.2045973Z + hexo-deployer-git@2.1.0
2020-07-17T09:37:15.2046392Z added 79 packages from 370 contributors and audited 80 packages in 3.303s
2020-07-17T09:37:15.2429274Z 
2020-07-17T09:37:15.2430418Z 2 packages are looking for funding
2020-07-17T09:37:15.2431026Z   run `npm fund` for details
2020-07-17T09:37:15.2431440Z 
2020-07-17T09:37:15.2436026Z found 1 low severity vulnerability
2020-07-17T09:37:15.2437039Z   run `npm audit fix` to fix them, or `npm audit` for details
2020-07-17T09:37:15.3654373Z internal/modules/cjs/loader.js:965
2020-07-17T09:37:15.3654831Z   throw err;
2020-07-17T09:37:15.3655161Z   ^
2020-07-17T09:37:15.3655337Z 
2020-07-17T09:37:15.3656238Z Error: Cannot find module 'hexo'
2020-07-17T09:37:15.3656577Z Require stack:
2020-07-17T09:37:15.3657053Z - /sync_deploy_history.js
2020-07-17T09:37:15.3657710Z     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
2020-07-17T09:37:15.3658184Z     at Function.Module._load (internal/modules/cjs/loader.js:838:27)
2020-07-17T09:37:15.3658600Z     at Module.require (internal/modules/cjs/loader.js:1022:19)
2020-07-17T09:37:15.3659005Z     at require (internal/modules/cjs/helpers.js:72:18)
2020-07-17T09:37:15.3659393Z     at Object.<anonymous> (/sync_deploy_history.js:8:14)
2020-07-17T09:37:15.3659777Z     at Module._compile (internal/modules/cjs/loader.js:1118:30)
2020-07-17T09:37:15.3660199Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
2020-07-17T09:37:15.3660620Z     at Module.load (internal/modules/cjs/loader.js:982:32)
2020-07-17T09:37:15.3661703Z     at Function.Module._load (internal/modules/cjs/loader.js:875:14)
2020-07-17T09:37:15.3662359Z     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
2020-07-17T09:37:15.3662797Z     at internal/main/run_main_module.js:17:47 {
2020-07-17T09:37:15.3663428Z   code: 'MODULE_NOT_FOUND',
2020-07-17T09:37:15.3663944Z   requireStack: [ '/sync_deploy_history.js' ]
2020-07-17T09:37:15.3664296Z }
2020-07-17T09:37:16.2666818Z Post job cleanup.
2020-07-17T09:37:16.3909530Z [command]/usr/bin/git version
2020-07-17T09:37:16.3991286Z git version 2.27.0
2020-07-17T09:37:16.4036709Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2020-07-17T09:37:16.4084281Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2020-07-17T09:37:16.4396802Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2020-07-17T09:37:16.4438360Z http.https://github.com/.extraheader
2020-07-17T09:37:16.4453229Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2020-07-17T09:37:16.4499878Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2020-07-17T09:37:16.4911900Z Cleaning up orphan processes
sma11black commented 4 years ago

In your error logs, it says:

  1. no such file or directory, open '/github/workspace/package.json'
  2. Error: Cannot find module 'hexo'

And your workflow config yaml is an incomplete configuration.

In my opinion, you should fix your configuration from the following aspects:

  1. Run the node dependencies installation step before running the hexo-action step. For details, please refer to the complete configuration example.
  2. You should check whether your hexo source code repository is complete. Only the index.md file is obviously not enough, you should commit the complete hexo source code directory.