Skip to content

Commit

Permalink
Don't try to push the python build image when building on release bra…
Browse files Browse the repository at this point in the history
…nches (apache#15394)

They use the same python image as master (as already mentioned in the
comments in ci_prepare_prod_image_on_ci.sh) so we don't want to try
and push the python image when we aren't building the main branch.
  • Loading branch information
ashb authored Apr 16, 2021
1 parent d115040 commit f94effe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1072,15 +1072,28 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
python-version: ${{ env.PYTHON_MAJOR_MINOR_VERSION }}
- name: "Free space"
run: ./scripts/ci/tools/ci_free_space_on_ci.sh
- name: Set push-python-image
id: push-python-image
run: |
if [[ "${REF}" == 'refs/head/master' || "${REF}" == 'refs/head/main' ]]; then
echo "::set-output name=wanted::true"
else
echo "::set-output name=wanted::false"
fi
env:
REF: ${{ github.ref }}
- name:
"Prepare PROD image ${{env.PYTHON_MAJOR_MINOR_VERSION}}:${{ env.GITHUB_REGISTRY_PULL_IMAGE_TAG }}"
run: ./scripts/ci/images/ci_prepare_prod_image_on_ci.sh
env:
# Since we are going to push both final image and build image segment, we need to pull the
# build image, in case we are pulling from registry rather than building.
WAIT_FOR_PROD_BUILD_IMAGE: "true"
WAIT_FOR_PYTHON_BASE_IMAGE: ${{ steps.push-python-image.outputs.wanted}}
- name: "Push PROD images ${{ matrix.python-version }}:${{ env.GITHUB_REGISTRY_PUSH_IMAGE_TAG }}"
run: ./scripts/ci/images/ci_push_production_images.sh
env:
PUSH_PYTHON_BASE_IMAGE: ${{ steps.push-python-image.outputs.wanted}}

push-ci-images-to-github-registry:
timeout-minutes: 10
Expand Down
10 changes: 6 additions & 4 deletions scripts/ci/images/ci_prepare_prod_image_on_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ function build_prod_images_on_ci() {
python_tag_suffix="-${GITHUB_REGISTRY_PULL_IMAGE_TAG}"
fi

# first we pull base python image. We will need it to re-push it after master build
# Becoming the new "latest" image for other builds
build_images::wait_for_image_tag "${GITHUB_REGISTRY_PYTHON_BASE_IMAGE}" \
"${python_tag_suffix}" "${AIRFLOW_PYTHON_BASE_IMAGE}"
if [[ "${WAIT_FOR_PYTHON_BASE_IMAGE=}" == "true" ]]; then
# first we pull base python image. We will need it to re-push it after master build
# Becoming the new "latest" image for other builds
build_images::wait_for_image_tag "${GITHUB_REGISTRY_PYTHON_BASE_IMAGE}" \
"${python_tag_suffix}" "${AIRFLOW_PYTHON_BASE_IMAGE}"
fi

# And then the actual image
build_images::wait_for_image_tag "${GITHUB_REGISTRY_AIRFLOW_PROD_IMAGE}" \
Expand Down
1 change: 0 additions & 1 deletion scripts/ci/libraries/_build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ function build_images::get_docker_image_names() {
export GITHUB_REGISTRY_PYTHON_BASE_IMAGE="${image_name}${image_separator}python${GITHUB_REGISTRY_IMAGE_SUFFIX}:${PYTHON_BASE_IMAGE_VERSION}-slim-buster"

export GITHUB_REGISTRY_AIRFLOW_CI_IMAGE="${image_name}${image_separator}${AIRFLOW_CI_BASE_TAG}${GITHUB_REGISTRY_IMAGE_SUFFIX}"
export GITHUB_REGISTRY_PYTHON_BASE_IMAGE="${image_name}${image_separator}python${GITHUB_REGISTRY_IMAGE_SUFFIX}:${PYTHON_BASE_IMAGE_VERSION}-slim-buster"
}

# If GitHub Registry is used, login to the registry using GITHUB_USERNAME and
Expand Down
5 changes: 3 additions & 2 deletions scripts/ci/libraries/_push_pull_remove_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ function push_pull_remove_images::push_python_image_to_github() {

# Pushes Ci images and their tags to registry in GitHub
function push_pull_remove_images::push_ci_images_to_github() {
push_pull_remove_images::push_python_image_to_github
if [[ "${PUSH_PYTHON_BASE_IMAGE=}" != "false" ]]; then
push_pull_remove_images::push_python_image_to_github
fi
AIRFLOW_CI_TAGGED_IMAGE="${GITHUB_REGISTRY_AIRFLOW_CI_IMAGE}:${GITHUB_REGISTRY_PUSH_IMAGE_TAG}"
docker_v tag "${AIRFLOW_CI_IMAGE}" "${AIRFLOW_CI_TAGGED_IMAGE}"
push_pull_remove_images::push_image_with_retries "${AIRFLOW_CI_TAGGED_IMAGE}"
Expand Down Expand Up @@ -263,7 +265,6 @@ function push_pull_remove_images::push_prod_images_to_dockerhub () {
# "${GITHUB_RUN_ID}" - in case of pull-request triggered 'workflow_run' builds
# "latest" - in case of push builds
function push_pull_remove_images::push_prod_images_to_github () {
push_pull_remove_images::push_python_image_to_github
AIRFLOW_PROD_TAGGED_IMAGE="${GITHUB_REGISTRY_AIRFLOW_PROD_IMAGE}:${GITHUB_REGISTRY_PUSH_IMAGE_TAG}"
docker_v tag "${AIRFLOW_PROD_IMAGE}" "${AIRFLOW_PROD_TAGGED_IMAGE}"
push_pull_remove_images::push_image_with_retries "${GITHUB_REGISTRY_AIRFLOW_PROD_IMAGE}:${GITHUB_REGISTRY_PUSH_IMAGE_TAG}"
Expand Down

0 comments on commit f94effe

Please sign in to comment.