I have a (simplified) GitHub workflow that looks like this:
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "build"
test:
runs-on: ubuntu-latest
needs: build
steps:
- run: echo "build"
deploy:
runs-on: ubuntu-latest
needs: [build, test]
steps:
- run: echo "deploy"
Now, I'd like to make it so that the deploy step only needs the tests step if the branch is main.
Is that possible?
Essentially I'd love to do something like this:
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "build"
test:
runs-on: ubuntu-latest
needs: build
steps:
- run: echo "build"
deploy:
runs-on: ubuntu-latest
needs: contains(branch, "master") ? [build, test] : [build] #notice this line
steps:
- run: echo "deploy"