Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow: update openapi.yml #497

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ jobs:
# Set default FORK_REPO and BRANCH_NAME values.
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}"
FORK_REPO="${GITHUB_HEAD_REPOSITORY:-${GITHUB_ACTOR}/openhospital-core}"
CHECK_BRANCH_URL="https://github.com/${GITHUB_ACTOR}/tree/$BRANCH_NAME"
CHECK_BRANCH_URL="https://github.com/${GITHUB_ACTOR}/openhospital-core/tree/$BRANCH_NAME"
echo "Checking branch existence with: curl -s -o /dev/null -w \"%{http_code}\" $CHECK_BRANCH_URL"

# Determine FORK_REPO with fallback logic
if [[ -n "${GITHUB_HEAD_REPOSITORY}" ]]; then
echo "Using ${GITHUB_HEAD_REPOSITORY}."
FORK_REPO=${GITHUB_HEAD_REPOSITORY}
elif curl -s -o /dev/null -w "%{http_code}" $CHECK_BRANCH_URL | grep -q "200"; then
echo "Checking branch existence with: curl -s -o /dev/null -w \"%{http_code}\" $CHECK_BRANCH_URL"
echo "Using ${GITHUB_ACTOR}/openhospital-core"
FORK_REPO=${GITHUB_ACTOR}/openhospital-core
else
echo "Using informatici/openhospital-core."
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,27 @@ 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}"
CHECK_BRANCH_URL="https://github.com/${GITHUB_ACTOR}/openhospital-core/tree/$BRANCH_NAME"
echo "Checking branch existence with: curl -s -o /dev/null -w \"%{http_code}\" $CHECK_BRANCH_URL"

# Determine FORK_REPO with fallback logic
if [[ -n "${GITHUB_HEAD_REPOSITORY}" ]]; then
echo "FORK_REPO=${GITHUB_HEAD_REPOSITORY}" >> $GITHUB_ENV
elif curl -s --head https://github.com/${GITHUB_ACTOR}/openhospital-core/tree/${BRANCH_NAME} | grep "HTTP/[12].* 2[0-9][0-9]" > /dev/null; then
echo "FORK_REPO=${GITHUB_ACTOR}/openhospital-core" >> $GITHUB_ENV
echo "Using ${GITHUB_HEAD_REPOSITORY}."
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"
FORK_REPO=${GITHUB_ACTOR}/openhospital-core
else
echo "FORK_REPO=informatici/openhospital-core" >> $GITHUB_ENV
echo "Using informatici/openhospital-core."
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
Loading