diff --git a/.github/workflows/behave.api.test.yml b/.github/workflows/behave.api.test.yml index e1130c8..eae29c7 100644 --- a/.github/workflows/behave.api.test.yml +++ b/.github/workflows/behave.api.test.yml @@ -1,17 +1,25 @@ name: Behave API Test on: - push: - branches: [develop] # Runs dev-tests + # PRs into develop or main (for dev/staging test runs) pull_request: - branches: [main] # Triggers on PRs *into* main (used for staging-tests) - workflow_dispatch: + branches: [develop, main] + types: [opened, synchronize, reopened, ready_for_review] + # Fire after PR is closed (for prod test run when merged) pull_request_target: - types: [closed] # Used for prod-tests (PR merged to main) + types: [closed] + # Manual run + workflow_dispatch: jobs: + # ------------------------- + # DEV: PRs into develop + # ------------------------- dev-tests: - if: github.ref == 'refs/heads/develop' + if: > + github.event_name == 'pull_request' && + github.event.pull_request.base.ref == 'develop' && + !github.event.pull_request.draft runs-on: ubuntu-latest environment: DEV @@ -38,8 +46,15 @@ jobs: name: behave-junit-report path: reports/ + # ------------------------- + # STAGING: PRs into main from staging branch + # ------------------------- staging-tests: - if: github.event.pull_request.head.ref == 'staging' && github.event.pull_request.base.ref == 'main' && !github.event.pull_request.merged + if: > + github.event_name == 'pull_request' && + github.event.pull_request.base.ref == 'main' && + github.event.pull_request.head.ref == 'staging' && + !github.event.pull_request.draft runs-on: ubuntu-latest environment: STAGING @@ -66,8 +81,14 @@ jobs: name: behave-junit-report path: reports/ + # ------------------------- + # PROD: when PR into main is merged + # ------------------------- prod-tests: - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' + if: > + github.event_name == 'pull_request_target' && + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'main' runs-on: ubuntu-latest environment: PROD