Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

构建失败 #30

Closed
MC-dusk opened this issue Oct 18, 2024 · 3 comments
Closed

构建失败 #30

MC-dusk opened this issue Oct 18, 2024 · 3 comments

Comments

@MC-dusk
Copy link

MC-dusk commented Oct 18, 2024

用的“普通安装”

github actions报错部分:

> @ deploy /home/runner/work/satlockss.github.io/satlockss.github.io
> cross-env NODE_ENV=action node ./tools/deploy.js

[remote] ***github.com/satlockss/satlockss.github.io.git
[mkdir] /home/runner/work/satlockss.github.io/satlockss.github.io/tmp is created
[git] cloning
[git] clone done
[cp] /home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/404.html
cp: cannot create directory '/home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io': No such file or directory
[cp] /home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/assets
[cp] /home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/cv-en.html
[cp] /home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/cv.html
cp: copyFileSync: could not write to dest file (code=ENOTDIR):/home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/icon.png
cp: cannot create directory '/home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io': No such file or directory
[cp] /home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/favicons
[cp] /home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/index.html
cp: copyFileSync: could not write to dest file (code=ENOTDIR):/home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/1.html
cp: cannot create directory '/home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io': No such file or directory
[cp] /home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io/posts
[git] deploying...
/home/runner/work/satlockss.github.io/satlockss.github.io/node_modules/.pnpm/[email protected]/node_modules/simple-git/dist/cjs/index.js:4018
    throw new GitConstructError(config, `Cannot use simple-git on a directory that does not exist`);
          ^

GitConstructError: Cannot use simple-git on a directory that does not exist
    at gitInstanceFactory (/home/runner/work/satlockss.github.io/satlockss.github.io/node_modules/.pnpm/[email protected]/node_modules/simple-git/dist/cjs/index.js:4018:11)
    at /home/runner/work/satlockss.github.io/satlockss.github.io/tools/deploy.js:59:5
    at onError2 (/home/runner/work/satlockss.github.io/satlockss.github.io/node_modules/.pnpm/[email protected]/node_modules/simple-git/dist/cjs/index.js:1796:7) {
  task: undefined,
  config: {
    baseDir: '/home/runner/work/satlockss.github.io/satlockss.github.io/tmp/satlockss.github.io',
    binary: 'git',
    maxConcurrentProcesses: 5,
    config: [],
    trimmed: false
  }
}

Node.js v18.20.4
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

image

@MC-dusk
Copy link
Author

MC-dusk commented Oct 18, 2024

看上去是deploy.js复制编译出的静态页面到对应目录,在push发布之前,复制出问题了,可能根本就没编译出来静态文件?

另外用户名satlockss和我不一样不用管,是其他号操作的

@MC-dusk
Copy link
Author

MC-dusk commented Oct 18, 2024

看了报错的都是我修改过文件,设置了路径的,突发奇想会不会是路径问题,重新建了一个repo,比如起名叫blog,把原来的所有东西复制粘贴进去,改了一下src/.vuepress/custom.js里面的一些路径,具体来说是:

  base: "/blog/",
...
      {
        name: "首页",
        link: "/blog"
      },
...
      {
        name: "CV",
        link: "/blog/cv.html"
      }

诶,问题解决了,一切正常部署了。

原来因为repo名字根据教程,设的是用户名,所以路径设的都是根目录:

  base: "/",
...
      {
        name: "首页",
        link: "/"
      },
...
      {
        name: "CV",
        link: "/cv.html"
      }

这种设置是有问题的,但感觉写的路径也没毛病,不知道问题在哪。

@MC-dusk
Copy link
Author

MC-dusk commented Oct 29, 2024

大概可以结案了,问题在于配置文件写的推送分支是master,而这个分支并不存在,需要提前手动创建,否则自动化action时会找不到路径报错。

教程的两种部署方式,里面的两个custom.js,也就是

https://github.com/Yidadaa/Issue-Blog-With-Github-Action/blob/source/template/custom.js

https://github.com/Yidadaa/Issue-Blog-With-Github-Action/blob/source/src/.vuepress/custom.js

写的都是master,要么改成main,要么手动创建master分支。

至于yml配置文件,里面的

on:
  push:
    branches:
      - source

这个是触发自动构建的分支,也就是响应哪个分支的变化/commit,可以酌情修改。

@MC-dusk MC-dusk closed this as completed Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant