Skip to content

Commit

Permalink
Update utils.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
kdivya153 authored Oct 12, 2024
1 parent 976af6e commit 66ea2ce
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,26 @@ function runTests(){
# Convert event name to lowercase
PR_BRANCH=$(echo "$EVENT_NAME" | tr '[:upper:]' '[:lower:]')

if [ "${PR_BRANCH}" == "pull_request" ]; then
# If it's a pull request event, use the PR branch
PR_BRANCH=$PR_HEAD_REF
elif [ "${PR_BRANCH}" == "push" ]; then
# For push events, extract the branch name
PR_BRANCH=$GITHUB_REF
PR_BRANCH="${PR_BRANCH#refs/heads/}"
elif [ "$EVENT_NAME" == "workflow_dispatch" ]; then
# If triggered by Repo A, check if PR branch exists and matches the one in Repo A
if [ -n "$OPENRPC_PR_BRANCH" ] && [ "$OPENRPC_PR_BRANCH" != "next" ]; then
# Check if OPENRPC_PR_BRANCH is not empty and event is repository_dispatch
if [ -n "$OPENRPC_PR_BRANCH" ] && [ "$PR_BRANCH" == "repository_dispatch" ]; then
PR_BRANCH=$OPENRPC_PR_BRANCH
echo "Using branch: $OPENRPC_PR_BRANCH"
else
PR_BRANCH="next"
echo "No matching PR branch found!!, checking out next branch."
fi
echo "Using branch from OPENRPC_PR_BRANCH: $OPENRPC_PR_BRANCH"
elif [ "$PR_BRANCH" == "pull_request" ]; then
# If it's a pull request event, use the PR branch
PR_BRANCH=$PR_HEAD_REF
elif [ "$PR_BRANCH" == "push" ]; then
# For push events, extract the branch name
PR_BRANCH=$GITHUB_REF
PR_BRANCH="${PR_BRANCH#refs/heads/}"
else
echo "Unsupported event: $EVENT_NAME"
exit 1
echo "No OPENRPC_PR_BRANCH set, defaulting to branch 'next'"
PR_BRANCH="next"
fi

echo "Cloning firebolt-apis repo with branch: $PR_BRANCH"
git clone --branch ${PR_BRANCH} https://github.com/rdkcentral/firebolt-apis.git
echo "cd to firebolt-apis repo and compile firebolt-open-rpc.json"
cd firebolt-apis
if [ "$EVENT_NAME" == "workflow_dispatch" ]; then
if [ "$EVENT_NAME" == "repository_dispatch" ]; then
# If OPENRPC_PR_BRANCH is set and is not 'next'
if [ -n "$OPENRPC_PR_BRANCH" ] && [ "$OPENRPC_PR_BRANCH" != "next" ]; then
echo "Updating OpenRPC dependency to branch: $OPENRPC_PR_BRANCH"
Expand Down Expand Up @@ -186,4 +180,4 @@ elif [ "$1" == "unzipArtifact" ]; then
else
echo "Invalid function specified."
exit 1
fi
fi

0 comments on commit 66ea2ce

Please sign in to comment.