Error using script deployment in github actions
rxliuli opened this issue · 1 comments
rxliuli commented
github repo: https://github.com/rxliuli/liuli-tools
error
➤ YN0000: 开始部署
➤ YN0000: (node:2160) UnhandledPromiseRejectionWarning: ProcessError: fatal: could not read Password for 'https://***@github.com': No such device or address
➤ YN0000:
➤ YN0000: at ChildProcess.<anonymous> (/home/runner/work/liuli-tools/liuli-tools/node_modules/gh-pages/lib/git.js:42:16)
➤ YN0000: at ChildProcess.emit (events.js:400:28)
➤ YN0000: at maybeClose (internal/child_process.js:1055:16)
➤ YN0000: at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
➤ YN0000: (Use `node --trace-warnings ...` to show where the warning was created)
➤ YN0000: (node:2160) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
➤ YN0000: (node:2160) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
➤ YN0000: Done in 13s 171ms
Department script
import { publish, PublishOptions } from 'gh-pages'
import path from 'path'
async function publishPromise(basePath: string, config: PublishOptions) {
await new Promise<void>((resolve, reject) => {
publish(basePath, config, (err) => {
if (err) {
reject(err)
}
resolve()
})
})
}
async function deploy() {
console.log(' 开始部署')
await publishPromise(path.resolve('bundles'), {
repo: `https://${process.env.GITHUB_TOKEN}@github.com/rxliuli/liuli-tools.git`,
dest: '/yarn-plugin-changed',
add: true,
user: {
name: 'github actions bot',
email: 'support+actions@github.com',
},
})
console.log(' 结束部署')
}
deploy()
kerryj89 commented
I was able to get this working.
- Make sure to pass in
GITHUB_TOKEN
... - run: | node deployment-script.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ...
- Change
https://${process.env.GITHUB_TOKEN}@github.com/rxliuli/liuli-tools.git
↓
https://x-access-token:${process.env.GITHUB_TOKEN}@github.com/rxliuli/liuli-tools.git