Skip to content

Commit

Permalink
testing for null, no solution yet, just debugging (#619)
Browse files Browse the repository at this point in the history
Co-authored-by: carebare47 <[email protected]>
  • Loading branch information
carebare47 and carebare47 authored Jul 29, 2024
1 parent 465d68f commit ecdd129
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
12 changes: 6 additions & 6 deletions docker/molecule/docker/bionic/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ phases:
docker: 19
build:
commands:
- echo $CODEBUILD_SOURCE_VERSION
- git --version
- |
if [[ $CODEBUILD_SOURCE_VERSION == "pr/"* ]]; then
pr_number=${CODEBUILD_SOURCE_VERSION#pr/}
branch=$(curl -s "https://api.github.com/repos/shadow-robot/aurora/pulls/$pr_number" | jq -r '.head.ref')
echo 'is_pr'
api_response=$(curl -s "https://api.github.com/repos/shadow-robot/aurora/pulls/$pr_number")
if [[ $(echo $api_response | jq -r '.head.ref') == 'null' ]]; then
echo "$api_response" | jq
echo "is null"
fi
branch=$(echo $api_response | jq -r '.head.ref')
elif [[ $CODEBUILD_SOURCE_VERSION =~ ^[0-9a-f]{40}$ ]]; then
echo 'is_hash'
branch=$(git ls-remote --symref origin | grep -m1 $CODEBUILD_SOURCE_VERSION | awk -F '/' '{print $NF}')
else
echo 'is_else'
branch=$CODEBUILD_SOURCE_VERSION
fi
- echo $branch
Expand Down
7 changes: 6 additions & 1 deletion docker/molecule/docker/focal/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ phases:
- |
if [[ $CODEBUILD_SOURCE_VERSION == "pr/"* ]]; then
pr_number=${CODEBUILD_SOURCE_VERSION#pr/}
branch=$(curl -s "https://api.github.com/repos/shadow-robot/aurora/pulls/$pr_number" | jq -r '.head.ref')
api_response=$(curl -s "https://api.github.com/repos/shadow-robot/aurora/pulls/$pr_number")
if [[ $(echo $api_response | jq -r '.head.ref') == 'null' ]]; then
echo "$api_response" | jq
echo "is null"
fi
branch=$(echo $api_response | jq -r '.head.ref')
elif [[ $CODEBUILD_SOURCE_VERSION =~ ^[0-9a-f]{40}$ ]]; then
branch=$(git ls-remote --symref origin | grep -m1 $CODEBUILD_SOURCE_VERSION | awk -F '/' '{print $NF}')
else
Expand Down
7 changes: 6 additions & 1 deletion docker/test/docker/bionic/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ phases:
- |
if [[ $CODEBUILD_SOURCE_VERSION == "pr/"* ]]; then
pr_number=${CODEBUILD_SOURCE_VERSION#pr/}
branch=$(curl -s "https://api.github.com/repos/shadow-robot/aurora/pulls/$pr_number" | jq -r '.head.ref')
api_response=$(curl -s "https://api.github.com/repos/shadow-robot/aurora/pulls/$pr_number")
if [[ $(echo $api_response | jq -r '.head.ref') == 'null' ]]; then
echo "$api_response" | jq
echo "is null"
fi
branch=$(echo $api_response | jq -r '.head.ref')
elif [[ $CODEBUILD_SOURCE_VERSION =~ ^[0-9a-f]{40}$ ]]; then
branch=$(git ls-remote --symref origin | grep -m1 $CODEBUILD_SOURCE_VERSION | awk -F '/' '{print $NF}')
else
Expand Down
7 changes: 6 additions & 1 deletion docker/test/docker/focal/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ phases:
- |
if [[ $CODEBUILD_SOURCE_VERSION == "pr/"* ]]; then
pr_number=${CODEBUILD_SOURCE_VERSION#pr/}
branch=$(curl -s "https://api.github.com/repos/shadow-robot/aurora/pulls/$pr_number" | jq -r '.head.ref')
api_response=$(curl -s "https://api.github.com/repos/shadow-robot/aurora/pulls/$pr_number")
if [[ $(echo $api_response | jq -r '.head.ref') == 'null' ]]; then
echo "$api_response" | jq
echo "is null"
fi
branch=$(echo $api_response | jq -r '.head.ref')
elif [[ $CODEBUILD_SOURCE_VERSION =~ ^[0-9a-f]{40}$ ]]; then
branch=$(git ls-remote --symref origin | grep -m1 $CODEBUILD_SOURCE_VERSION | awk -F '/' '{print $NF}')
else
Expand Down

0 comments on commit ecdd129

Please sign in to comment.