首页 > 解决方案 > 使用 Github 操作的 Cypress <> Heroku 集成

问题描述

我想使用 github 操作将 cypress 与 heroku 管道集成。以下是我尝试过的以及我面临的问题。

我在我的 vuejs 项目中创建了一个端到端测试,并添加了 github 工作流程,如下所示

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ master ]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: echo Running e2e tests on cypress!
      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        run: npm run install && npm run build && npm run cypress:run

问题是,每当我将代码推送到 github master 分支时,都会在 heroku 和 github 中进行构建。

我不希望这种情况发生。我希望构建只发生在heroku中。然后在 heroku 中构建完成后,在 heroku 服务器中使用 cypress 和 github 操作运行端到端测试。我怎样才能做到这一点?

标签: githubherokucypressgithub-actions

解决方案


推荐阅读