Skip to content

Commit

Permalink
workaround in using variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mwithi committed Oct 30, 2024
1 parent dc368e4 commit 591581f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ jobs:
- name: Determine PR source branch and fork repository
id: vars
run: |
# Set BRANCH_NAME based on event type
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
else
echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
fi
# Set default FORK_REPO and BRANCH_NAME values.
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}"
FORK_REPO="${GITHUB_HEAD_REPOSITORY:-${GITHUB_ACTOR}/openhospital-core}"
# Log and check if the branch exists in the contributor’s fork
CHECK_BRANCH_URL="https://github.com/${GITHUB_ACTOR}/tree/$BRANCH_NAME"
Expand All @@ -41,14 +38,18 @@ jobs:
# Determine FORK_REPO with fallback logic
if [[ -n "${GITHUB_HEAD_REPOSITORY}" ]]; then
echo "Using ${GITHUB_HEAD_REPOSITORY}."
echo "FORK_REPO=${GITHUB_HEAD_REPOSITORY}" >> $GITHUB_ENV
FORK_REPO=${GITHUB_HEAD_REPOSITORY}
elif curl -s -o /dev/null -w "%{http_code}" $CHECK_BRANCH_URL | grep -q "200"; then
echo "Using ${GITHUB_ACTOR}/openhospital-core."
echo "FORK_REPO=${GITHUB_ACTOR}/openhospital-core" >> $GITHUB_ENV
FORK_REPO=${GITHUB_ACTOR}/openhospital-core
else
echo "Using informatici/openhospital-core."
echo "FORK_REPO=informatici/openhospital-core" >> $GITHUB_ENV
FORK_REPO="informatici/openhospital-core"
fi
# Export FORK_REPO and BRANCH_NAME to GITHUB_ENV for the next step
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "FORK_REPO=$FORK_REPO" >> $GITHUB_ENV
- name: Log variables
run: |
Expand Down

0 comments on commit 591581f

Please sign in to comment.