diff --git a/action.yml b/action.yml index 8deb73f2..aadc519c 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,10 @@ inputs: description: 'Log level for the rootstock-integration-tests' required: false default: 'info' + repo-owner: + description: 'The owner of the repository' + required: false + default: 'rsksmart' outputs: status: @@ -34,3 +38,4 @@ runs: INPUT_POWPEG_NODE_BRANCH: ${{ inputs.powpeg-node-branch }} INPUT_RIT_BRANCH: ${{ inputs.rit-branch }} INPUT_RIT_LOG_LEVEL: ${{ inputs.rit-log-level }} + INPUT_REPO_OWNER: ${{ inputs.repo-owner }} \ No newline at end of file diff --git a/container-action/entrypoint.sh b/container-action/entrypoint.sh index 1003f44d..0cd21f4d 100644 --- a/container-action/entrypoint.sh +++ b/container-action/entrypoint.sh @@ -5,23 +5,55 @@ RSKJ_BRANCH="${INPUT_RSKJ_BRANCH}" POWPEG_NODE_BRANCH="${INPUT_POWPEG_NODE_BRANCH}" RIT_BRANCH="${INPUT_RIT_BRANCH}" LOG_LEVEL="${INPUT_RIT_LOG_LEVEL}" +REPO_OWNER="${INPUT_REPO_OWNER:-rsksmart}" # Default to 'rsksmart' if not provided + +# Check if the branch exists +IS_RSKJ_BRANCH=$(curl -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/$REPO_OWNER/rskj/branches/$RSKJ_BRANCH") + +if [ "$IS_RSKJ_BRANCH" -eq 200 ]; then + echo "IS_RSKJ_BRANCH is true: Branch '$RSKJ_BRANCH' exists in $REPO_OWNER/rskj.git" +else + echo "Branch '$RSKJ_BRANCH' does not exist in $REPO_OWNER/rskj.git" +fi + +IS_POWPEG_BRANCH=$(curl -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/$REPO_OWNER/powpeg-node/branches/$POWPEG_NODE_BRANCH") + +if [ "$IS_POWPEG_BRANCH" -eq 200 ]; then + echo "IS_POWPEG_BRANCH is true: Branch '$POWPEG_NODE_BRANCH' exists in $REPO_OWNER/powpeg-node.git" +else + echo "Branch '$POWPEG_NODE_BRANCH' does not exist in $REPO_OWNER/powpeg-node.git" +fi + echo -e "\n\n--------- Input parameters received ---------\n\n" echo "RSKJ_BRANCH=$RSKJ_BRANCH" echo "POWPEG_NODE_BRANCH=$POWPEG_NODE_BRANCH" echo "RIT_BRANCH=$RIT_BRANCH" echo "LOG_LEVEL=$LOG_LEVEL" +echo "REPO_OWNER=$REPO_OWNER" echo -e "\n\n--------- Starting the configuration of rskj ---------\n\n" cd /usr/src/ -git clone https://github.com/rsksmart/rskj.git rskj +if [ "$IS_RSKJ_BRANCH" -eq 200 ]; then + echo "Found matching branch name in $REPO_OWNER/rskj.git repo" + git clone "https://github.com/$REPO_OWNER/rskj.git" rskj +else + echo "Found matching branch name in rsksmart/rskj.git repo" + git clone "https://github.com/rsksmart/rskj.git" rskj +fi cd rskj && git checkout "$RSKJ_BRANCH" chmod +x ./configure.sh && chmod +x gradlew ./configure.sh echo -e "\n\n--------- Starting the configuration of powpeg ---------\n\n" cd /usr/src/ -git clone https://github.com/rsksmart/powpeg-node.git powpeg +if [ "$IS_POWPEG_BRANCH" -eq 200 ]; then + echo "Found matching branch name in $REPO_OWNER/powpeg-node.git repo" + git clone "https://github.com/$REPO_OWNER/powpeg-node.git" powpeg +else + echo "Found matching branch name in rsksmart/powpeg-node.git repo" + git clone "https://github.com/rsksmart/powpeg-node.git" powpeg +fi cp configure_gradle_powpeg.sh powpeg cd powpeg && git checkout "$POWPEG_NODE_BRANCH" chmod +x ./configure.sh && chmod +x gradlew