Reputation: 41
I need github actions to run only on the QAS branch and deploy event. It should run on 'pull_request' and 'pull' and only on the QAS branch.
name: Cypress
on: [deployment_status]
jobs:
e2e:
if: github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
steps:
- name: Print URL
run: echo Testing URL ${{ github.event.deployment_status.target_url }}
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2-beta
with:
node-version: 14
- name: Install modules
run: yarn
- name: Run Cypress
uses: cypress-io/github-action@v2
But I wanted something like this:
name: Cypress
on:
deployment_status:
pull_request:
branches:
- qas
push:
branches:
- qas
jobs:...
Upvotes: 3
Views: 2335
Reputation: 23040
It's currently not possible to achieve what you want using triggers conditions alone. This is due to the fact that those conditions are configured to work as OR
and not as AND
.
It that case, a workaround is to use one trigger condition - for example the on: [deployment_status]
you are currently using - then add a filter at the job level to check the branch name based on the github.ref
from the Github Context.
In your case, I guess it would look like this:
name: Cypress
on: [deployment_status]
jobs:
e2e:
if: ${{ github.event.deployment_status.state == 'success' && github.ref == 'refs/heads/qas' }}
runs-on: ubuntu-latest
steps:
[...]
Note: Let me know if the job if condition
is working as expected (I don't have a poc repo with a webhook configured to try it with the github.event.deployment_status.state
as well).
Note 2: It may not be necessary to use the ${{ }}
around the condition:
if: github.event.deployment_status.state == 'success' && github.ref == 'refs/heads/qas'
Upvotes: 1