6

Similar tho this question How to run Github Actions with the 'deployment_status' kitty and only on the QAS branch? I want to execute a workflow only on a specific branch but combined with the deployment_status trigger.

So I want to execute my end to end test only if the deployment is done and we are on the develop branch.

The problem here is: On the trigger deployment_status the github.ref variable is not set. It is also written in docs. So I can not do a manual check if I am on the right branch.

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 }}

On the other way: If i use the deployment_status trigger I can not use branches or branches-ignore in combination. This is not working at all.

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 }}

Any ideas how to solve this?

Tobi
  • 674
  • 5
  • 20
  • 3
    Looks like the variable `github.event.deployment.environment` give me at least the environment from vercel. So I know if this was a `preview` build or an `production` build. – Tobi Oct 22 '21 at 16:17

0 Answers0