简体   繁体   English

如何运行 node.js github 存储库作为 github 操作上另一个存储库中的服务

[英]how to run a node.js github repository as a service in another repository on github actions

So I have a project that needs a "fake" API to do some functional testing on user scenarios;所以我有一个项目需要一个“假”的API对用户场景做一些功能测试; so my idea was creating a simple little node.js project and getting to return some dummy json data depending on a few endpoints to test several use cases of my application.所以我的想法是创建一个简单的小 node.js 项目并根据几个端点返回一些虚拟 json 数据来测试我的应用程序的几个用例。

I have a separate repository containing this fake API and I'm wondering how I should go about adding it into my github actions workflow?我有一个单独的存储库,其中包含这个假的 API,我想知道我应该如何 go 将其添加到我的 github 操作工作流程中?

You can use actions/checkout@v2 to pull another repo into your worker.您可以使用actions/checkout@v2将另一个 repo 拉入您的工作人员。

See the example below:请参见下面的示例:

name: PullExternalRepo

on: workflow_dispatch

jobs:
  PullRepo:
    runs-on: ubuntu-latest
      - name: Install Node
        uses: actions/setup-node@v2-beta
        with:
          node-version: '12'
      - name: Install external repo
        uses: actions/checkout@v2
        with:
          repository: your_org/repo_name
          path: './place/to/clone/repo/into'
      - name: Install deps and run
        run: |
          cd ./place/to/clone/repo/into
          npm install
          npm start

Added note about pulling specific branches:添加了有关拉取特定分支的注释:

If you are trying to pull a non-default branch, you need to add the ref property to the checkout action, as seen in the example below.如果您尝试拉出非默认分支,则需要将ref属性添加到 checkout 操作,如下例所示。

...
      - name: Install external repo
        uses: actions/checkout@v2
        with:
          repository: your_org/repo_name
          path: './place/to/clone/repo/into'
          ref: 'some-other-branch'
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM