【问题标题】:Knex.js migration not working from Github ActionKnex.js 迁移在 Github Action 中不起作用
【发布时间】:2021-01-06 05:43:05
【问题描述】:

我在 Github Action 上遇到了这个有线问题,它使用 Objection.JS ORM 部署 NodeJS。它工作正常,我已经为它编写了迁移数据库的命令。

    "migrate": "knex migrate:latest --env production"

如果我 ssh 进入服务器并运行上面的命令,它工作正常,但我有执行相同命令的 GitHub 操作,但它失败了。我想这可能与环境变量有关。从 GitHub 操作执行的命令是否可以访问环境变量?

这是 Github Action 中的错误:

out: > knex migrate:latest --env production
135
out: 
136
out: Requiring external module ts-node/register
137
out: Using environment: production
138
err: error: password authentication failed for user "***"
139
err:     at Parser.parseErrorMessage (/home/***/odin/odin/node_modules/pg-protocol/src/parser.ts:357:11)
140
err:     at Parser.handlePacket (/home/***/odin/odin/node_modules/pg-protocol/src/parser.ts:186:21)
141
err:     at Parser.parse (/home/***/odin/odin/node_modules/pg-protocol/src/parser.ts:101:30)
142
err:     at Socket.<anonymous> (/home/***/odin/odin/node_modules/pg-protocol/src/index.ts:7:48)
143
err:     at Socket.emit (events.js:315:20)
144
err:     at addChunk (_stream_readable.js:295:12)
145
err:     at readableAddChunk (_stream_readable.js:271:9)
146
err:     at Socket.Readable.push (_stream_readable.js:212:10)
147
err:     at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
148
err: npm ERR! code ELIFECYCLE
149
err: npm ERR! errno 1
150
err: npm ERR! app@1.0.0 migrate: `knex migrate:latest --env production`

这是 GitHub 操作脚本:

 script: |
          cd ~/app/app
          git pull origin master
          npm install --production
          npm run build
          npm run migrate
          pm2 restart digthemes

【问题讨论】:

    标签: node.js knex.js github-actions


    【解决方案1】:

    这看起来不像是 knex 问题。您的环境变量有问题,根据错误消息,密码或用户设置不正确。

    关于 GA 中的环境变量,请参见:https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables

    【讨论】:

      猜你喜欢
      • 2019-08-29
      • 2020-10-02
      • 1970-01-01
      • 2023-03-14
      • 2014-05-02
      • 2012-09-08
      • 2020-10-25
      • 2022-06-13
      • 2021-10-17
      相关资源
      最近更新 更多