so basically the project I’m working on has a github actions workflow file that looks like this:
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "flom_v1_development" branch
push:
branches: ["development"]
pull_request:
branches: ["development"]
types:
- closed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: self-hosted
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
clean: false
AND SO ON...
as you can see there are 2 events: push & pull request
what I have found so far on SO is that if I put an if before “steps” that checks whether a PR has merged it will stop the double run. BUT, then “pull” doesn’t run either!
I’ve tried solving that like this:
# Steps represent a sequence of tasks that will be executed as part of the job
if: github.event_name == 'push' || github.event.pull_request.merged == true
steps:
AND SO ON...
but it still runs twice on PR
I’m at the end of my rope here, any help?
BTW is there any particular reason why the github docs sometimes use this style for if statements
if: ${{ github.event.issue.pull_request }}
and sometimes what I posted previously (no dollar-sign + curly braces)?