Skip to content

Commit

Permalink
with ref_name
Browse files Browse the repository at this point in the history
  • Loading branch information
rshunim committed Sep 19, 2023
1 parent 5ea727f commit 870876f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ on:
push:
jobs:
docker_build:
env:
BRANCH_NAME: ${{github.ref_name}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
14 changes: 7 additions & 7 deletions docker/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function docker_build {
image_name=$(basename $1)
echo "Starting build for dir: $1, image: ${image_name}, pwd: $(pwd)"
cd $1
if [[ "$CIRCLE_BRANCH" == "master" ]] && [[ "$(prop 'devonly')" ]]; then
if [[ "$BRANCH_NAME" == "master" ]] && [[ "$(prop 'devonly')" ]]; then
echo "== skipping image [${image_name}] as it is marked devonly =="
return 0
fi
Expand Down Expand Up @@ -337,7 +337,7 @@ function docker_build {
fi
if ! ${DOCKER_SRC_DIR}/post_github_comment.py ${image_full_name}; then
echo "Failed post_github_comment.py. Will stop build only if not on master"
if [ "$CIRCLE_BRANCH" == "master" ]; then
if [ "$BRANCH_NAME" == "master" ]; then
echo "Continuing as we are on master branch..."
else
echo "failing build!!"
Expand All @@ -346,7 +346,7 @@ function docker_build {
fi
else
echo "Skipping docker push"
if [ "$CIRCLE_BRANCH" == "master" ]; then
if [ "$BRANCH_NAME" == "master" ]; then
echo "Did not push image on master. Failing build"
exit 1
fi
Expand Down Expand Up @@ -378,14 +378,14 @@ EOF
}

# default compare circle branch against master
DIFF_COMPARE=origin/master...${CIRCLE_BRANCH}
DIFF_COMPARE=origin/master...${BRANCH_NAME}

if [ -z "$CIRCLE_SHA1" ]; then
echo "CIRCLE_SHA1 not set. Assuming local testing."
CIRCLE_SHA1=testing
DOCKER_ORG=${DOCKER_ORG:-devtesting}

if [ -z "$CIRCLE_BRANCH" ]; then
if [ -z "$BRANCH_NAME" ]; then
# simply compare against origin/master
DIFF_COMPARE=origin/master
fi
Expand Down Expand Up @@ -421,7 +421,7 @@ if [[ -n "$1" ]]; then
DOCKER_INCLUDE_GREP="/${1}$"
fi

if [ "$CIRCLE_BRANCH" == "master" ]; then
if [ "$BRANCH_NAME" == "master" ]; then
# on master we use the range obtained from CIRCLE_COMPARE_URL
# example of comapre url: https://github.com/demisto/content/compare/62f0bd03be73...1451bf0f3c2a
# if there wasn't a successful build CIRCLE_COMPARE_URL is empty. We set diff compare to special ALL
Expand All @@ -438,7 +438,7 @@ if [ "$CIRCLE_BRANCH" == "master" ]; then
DOCKER_ORG=demisto
fi

echo "DOCKER_ORG: ${DOCKER_ORG}, DIFF_COMPARE: [${DIFF_COMPARE}], SCRIPT_DIR: [${SCRIPT_DIR}], CIRCLE_BRANCH: ${CIRCLE_BRANCH}, PWD: [${CURRENT_DIR}]"
echo "DOCKER_ORG: ${DOCKER_ORG}, DIFF_COMPARE: [${DIFF_COMPARE}], SCRIPT_DIR: [${SCRIPT_DIR}], BRANCH_NAME: ${BRANCH_NAME}, PWD: [${CURRENT_DIR}]"

# echo to bash env to be used in future steps
CIRCLE_ARTIFACTS="artifacts"
Expand Down

0 comments on commit 870876f

Please sign in to comment.