Here is my sample GitHub workflow:
name: APP Build
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- feature/test
jobs:
check-environment:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/}| sed 's/\//-/g')"
id: extract_branch
test:
runs-on: ubuntu-latest
needs: check-environment
steps:
- name: echo
run: echo ${{ steps.extract_branch.outputs.branch }}
I have these 3 problem:
Once PR is created and I push some changes, this triggered 2 builds. One for the
pull_request:and one forpush:. How to make sure when both ison:condition is met then trigger only 1 build?When build is trigger by the push on branch. I get the output of
echo ${{ steps.extract_branch.outputs.branch }}:feature-test. Which is expected but when build is trigger by pull request sameecho ${{ steps.extract_branch.outputs.branch }}becomes refs-pull-2-merge. How to still get branch name for the pull request?How to make job name test run only for Pull request build. For Push only check-environment should be run and for pull request both the job should run. I know there is if condition but how to make it run for pull request(new PR and update on PR)