[英]How can I run multiple Node App in a Github Actions?
This is my actions这是我的行动
# This is a basic workflow to help you get started with Actions
name: CI/CD Akper Bina Insan - Live
on:
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Yarn
run: npm install -g yarn
- name: Build UI - Akper Bina Insan
working-directory: ./ui
run: yarn && yarn build && yarn start
- name: Build Backend Service - Akper Bina Insan
working-directory: ./be
run: yarn && yarn build && yarn prod
After it finished with the first run, it don't go continue with the second run.完成第一次运行后,它不会 go 继续第二次运行。 Even though the server is ready.即使服务器已准备就绪。 I waited for 5 minutes then I stopped since I don't want to waste time.我等了 5 分钟然后我停下来,因为我不想浪费时间。
How can I make it run for the second one?我怎样才能让它运行第二个?
GitHub actions are a tool for CI/CD and not for hosting (running) your application. GitHub 操作是用于 CI/CD 的工具,而不是用于托管(运行)您的应用程序。
In the given workflows, you build
an then run
your UI application.在给定的工作流程中,您build
一个然后run
您的 UI 应用程序。 The run command is a blocking process - eg your workflow will remain blocked because you have started your UI application.运行命令是一个阻塞过程——例如,您的工作流程将保持阻塞,因为您已经启动了您的 UI 应用程序。 You should not do that in workflows.您不应该在工作流程中这样做。
Use GitHub Action for build and test, but not for hosting.使用 GitHub 操作进行构建和测试,但不用于托管。
Adding an ending &
to the node command solved this for my use-case在节点命令中添加结尾&
解决了我的用例
run: yarn && yarn build && yarn start &
or或者
run: |
yarn
yarn build
yarn start &
Using &
in the end of a command, the shell executes the command in the background in a subshell, therefore running the first yarn start
won't be blocking your next step in the workflow.在命令末尾使用&
,shell 在后台子shell 中执行命令,因此运行第一个yarn start
不会阻止您在工作流中的下一步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.