github工作流程仅在deployment_status和特定分支上

问题描述 投票:0回答:1

与此问题类似如何使用“deployment_status”kitty 并仅在 QAS 分支上运行 Github Actions? 我只想在特定分支上执行工作流程,但与

deployment_status
触发器结合使用。

因此,只有在部署完成并且我们位于

develop
分支上时,我才想执行端到端测试。

这里的问题是:在触发器

deployment_status
上,未设置
github.ref
变量。它也写在文档中。所以我无法手动检查我是否在正确的分支上。

name: E2E

on:
  deployment_status:
    # does not work because it is ignored on deployment_status
    branches:
      - develop
      - stage
      - master
      - main

jobs:
  chrome:
    if: github.event.deployment_status.state == 'success'
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      
      - name: Run Cypress
        uses: cypress-io/github-action@v2
        with:
          browser: chrome
          cache-key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
        env:
          CYPRESS_BASE_URL: ${{ github.event.deployment_status.target_url }}

另一方面:如果我使用

deployment_status
触发器,我无法组合使用
branches
branches-ignore
。这根本不起作用。

name: E2E

on:
  deployment_status:

jobs:
  chrome:
    # does not work because github.ref is not defined
    if: github.event.deployment_status.state == 'success' && github.ref == 'refs/heads/develop' /
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      
      - name: Run Cypress
        uses: cypress-io/github-action@v2
        with:
          browser: chrome
          cache-key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
        env:
          CYPRESS_BASE_URL: ${{ github.event.deployment_status.target_url }}

有什么想法可以解决这个问题吗?

github github-actions vercel
1个回答
0
投票

所有功劳都归功于上面@Tobi 的评论!

我一直在尝试在所有分支上针对 Vercel + Strapi 设置运行剧作家测试,但 main

 除外。我找不到通过 push
pull_request
忽略分支的方法,同时仍然可以访问
deployment_status.environment_url
Tobi 检查环境(即预览或生产)的解决方案至少是一个可以使用的解决方案。

name: Playwright Tests on: deployment_status: jobs: test: timeout-minutes: 60 if: github.event.deployment.environment == 'Preview' && github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: lts/* - name: Environment URL run: echo ${{ github.event.deployment_status.environment_url }} - name: Environment run: echo ${{ github.event.deployment.environment }}

© www.soinside.com 2019 - 2024. All rights reserved.