Skip to content

Commit

Permalink
Use ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
Browse files Browse the repository at this point in the history
Default to using the bare branch name in GITHUB_HEAD_REF
when it's available in a PR, and will fall back to parsing
it out of the GITHUB_REF when operating on a branch
in a push workflow, where "refs/heads" will be correct.
  • Loading branch information
vkmc committed Sep 13, 2024
1 parent 6a2a6df commit 04fe580
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ jobs:
id: bridge_branch
continue-on-error: true
run: |
echo "refs/heads/${GITHUB_HEAD_REF}"
git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")"
echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")"
- name: Start sg-bridge from container image
if: steps.bridge_branch.outcome != 'success'
run: |
Expand Down Expand Up @@ -158,8 +158,8 @@ jobs:
id: bridge_branch
continue-on-error: true
run: |
echo "refs/heads/${GITHUB_HEAD_REF}"
git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")"
echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")"
- name: Start sg-bridge from container image
if: steps.bridge_branch.outcome != 'success'
run: |
Expand Down Expand Up @@ -323,8 +323,8 @@ jobs:
id: bridge_branch
continue-on-error: true
run: |
echo "refs/heads/${GITHUB_HEAD_REF}"
git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")"
echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")"
- name: Start sg-bridge from container image
if: steps.bridge_branch.outcome != 'success'
run: |
Expand Down
2 changes: 1 addition & 1 deletion ci/integration/logging/run_bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-OpsTools.repo
dnf install -y git gcc make qpid-proton-c-devel redhat-rpm-config

# install and start sg-bridge
BRANCH="$(echo "refs/heads/${GITHUB_HEAD_REF}")"
BRANCH="$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")"
git clone https://github.com/infrawatch/sg-bridge.git
pushd sg-bridge
git checkout $BRANCH || true
Expand Down
2 changes: 1 addition & 1 deletion ci/integration/metrics/run_bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-OpsTools.repo
dnf install -y git gcc make qpid-proton-c-devel redhat-rpm-config

# install and start sg-bridge
BRANCH="$(echo "refs/heads/${GITHUB_HEAD_REF}")"
BRANCH="$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")"
git clone https://github.com/infrawatch/sg-bridge.git
pushd sg-bridge
git checkout $BRANCH || true
Expand Down

0 comments on commit 04fe580

Please sign in to comment.