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

Tob*_*obi 7 github vercel github-actions

与此问题类似How to run Github Actions with the 'deployment_status' kitty and only on the QAS Branch? 我想仅在特定分支上执行工作流程,但与deployment_status触发器结合使用。

因此,我只想在部署完成并且我们位于分支上时才执行端到端测试develop

这里的问题是:在触发器上未设置变量deployment_statusgithub.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 }}
Run Code Online (Sandbox Code Playgroud)

另一方面:如果我使用触发器,deployment_status我就不能使用branchesbranches-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 }}
Run Code Online (Sandbox Code Playgroud)

有什么想法如何解决这个问题吗?