[英]heroku deployment with ci/cd
我正在嘗試使用 github 操作構建 CI/CD 管道,以便構建我的應用程序並將其部署到 heroku。 我使用了以下 YAML 文件。 但它在 github 操作中顯示錯誤。 誰能幫我解決這個問題。 我的倉庫是bigshopcicd 。我的項目結構是 bigshop |-backend |-frontend |-package.json
錯誤-
Run npm run build
sh:1:反應腳本:未找到
npm 錯誤。 代碼 ELIFECYCLE npm 錯誤。 系統調用產生 npm ERR:文件 sh npm ERR! errno ENOENT npm 錯誤! frontend@0.1.0 build: react-scripts build
npm 錯誤! 生成 ENOENT
bigshop@1.0.0 build /home/runner/work/bigshopcicd/bigshopcicd cd frontend && npm 運行構建
frontend@0.1.0 build /home/runner/work/bigshopcicd/bigshopcicd/frontend react-scripts build
npm 錯誤。 npm 錯誤。 在 frontend@0.1.0 構建腳本中失敗。 npm 錯誤。 This is probably not a problem with npm, There is likely additional logging output above, npm WARN Local package?json exists, but node_modules missing, did you mean to install?
npm ERR:此運行的完整日志可在 npm ERR 中找到。 /home/runner/.npm/_logs/2021-12-23T08_13_25_954Z-debug.log npm ERR:代碼ELIFECYCLE npm ERR! 錯誤號 1 npm 錯誤! bigshop@1.0.0 build: cd frontend && npm run build
npm ERR。 退出狀態 1 npm ERR。 npm 錯誤。 bigshop@1.0.0 構建腳本失敗。 npm 錯誤! 這可能不是 npm 的問題。 上面可能還有額外的日志記錄 output。
npm ERR:此運行的完整日志可在 npm ERR 中找到。 /home/runner/:npm/_logs/2021-12-23T08_13_25_975Z-debug.log 錯誤:進程完成,退出代碼為 1。
pipeline.yml-
name: Deployment pipeline
on:
push:
branches:
- main
pull_request:
branches: [main]
types: [opened, synchronize]
jobs:
simple_deployment_pipeline:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: npm install
run: npm install
- name: build
run: npm run build
- name: deployment
uses: akhileshns/heroku-deploy@v3.12.12
if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' ,'), '#skip') }}
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: bigshopcicd
heroku_email: fakirsumon78@gmmail.com
healthcheck: 'https://bigshopcicd.herokuapp.com/health'
checkstring: 'ok'
rollbackonhealthcheckfailed: true
- uses: actions/checkout@v2
- name: Bump version and push tag
uses: anothrNick/github-tag-action@eca2b69f9e2c24be7decccd0f15fdb1ea5906598
if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' ,'), '#skip') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
RELEASE_BRANCHES: main
package.json文件-
"scripts": {
"start": "node backend/server.js",
"dev": "set NODE_ENV=DEVELOPMENT& nodemon backend/server",
"prod": "set NODE_ENV=PRODUCTION& nodemon backend/server",
"seeder": "node backend/utils/seeder.js",
"build": "cd frontend && npm run build",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false && npm install --prefix frontend && npm run build --prefix frontend"
},
您的 npm 安裝命令在不包含反應依賴項的根 package.json 中運行安裝。 然后構建步驟進入 ./frontend 並嘗試使用那些未獲取的反應腳本。
您可以使用 npm 的preinstall
目標來安裝前端依賴項。
還請嘗試查看是否可以將項目拆分為兩個不同的項目,因為這種結構看起來很脆弱,並且您實際上失去了擁有單獨的后端/前端的優勢。 (加上你的腳本變得過於復雜)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.