与此问题类似,如何使用“deployment_status”小猫仅在 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 }}
任何想法如何解决这个问题?