Skip to content

Commit

Permalink
Merge pull request #700 from gerrod3/app-fixes-2
Browse files Browse the repository at this point in the history
More fixes to app-rebuild logic
  • Loading branch information
gerrod3 authored Dec 10, 2024
2 parents 33ec895 + a844d50 commit 981069c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .github/actions/build_image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ outputs:
value: ${{ steps.image_version_branch.outputs.app_branch }}
description: 'The pulpcore version branch that the built image matches'
rebuilt_images:
value: ${{ env.BUILD }}
value: ${{ steps.rebuild_needed.outputs.build }}
description: 'true/false if the app image was rebuilt'

runs:
Expand Down Expand Up @@ -80,6 +80,7 @@ runs:
path: versions.freeze

- name: Check if rebuild is needed
id: rebuild_needed
run: |
# Rebuilds are needed for
# 1. CI is being ran in a PR or is a nightly run
Expand All @@ -89,17 +90,18 @@ runs:
if [[ "${{ github.event_name }}" != "pull_request" && "${{ inputs.image_variant }}" != "nightly" && -z "${{ inputs.built_base_images }}" ]]; then
if [[ "${{ steps.cache.outputs.cache-hit }}" == "true" ]]; then
# Script returns non-zero (100) when new versions are available
cat versions.freeze
if python .ci/scripts/check_up_to_date.py ${{ github.ref_name }} versions.freeze; then
build=false
fi
fi
fi
echo "BUILD=${build}" >> $GITHUB_ENV
echo "build=${build}" >> "$GITHUB_OUTPUT"
echo "Going to rebuild: ${build}"
shell: bash

- name: Build images
if: env.BUILD == 'true'
if: steps.rebuild_needed.outputs.build == 'true'
run: |
podman version
buildah version
Expand All @@ -121,9 +123,13 @@ runs:
id: image_version_branch
run: |
base_image=$(echo ${{ inputs.image_name }} | cut -d '-' -f1)
app_version=$(podman run --pull=never pulp/${{ inputs.image_name }}:ci-amd64 bash -c "pip3 show pulpcore | sed -n -e 's/Version: //p'")
if [[ "${{ steps.rebuild_needed.outputs.build }}" == "true" ]]; then
app_version=$(podman run --pull=never pulp/${{ inputs.image_name }}:ci-amd64 bash -c "pip3 show pulpcore | sed -n -e 's/Version: //p'")
podman run --pull=never pulp/${{ inputs.image_name }}:ci-amd64 bash -c "pip3 freeze | grep pulp" > versions.freeze
else
app_version=$(grep pulpcore versions.freeze | sed -n -e 's/pulpcore==//p')
fi
app_branch=$(echo ${app_version} | grep -oP '\d+\.\d+')
podman run --pull=never pulp/${{ inputs.image_name }}:ci-amd64 bash -c "pip3 freeze | grep pulp" > versions.freeze
echo "APP_VERSION: ${app_version}"
echo "APP_BRANCH: ${app_branch}"
Expand All @@ -133,14 +139,14 @@ runs:
shell: bash

- name: Clear cache for next upload
if: env.BUILD == 'true' && steps.cache.outputs.cache-hit == 'true' && github.event_name != 'pull_request'
if: steps.rebuild_needed.outputs.build == 'true' && steps.cache.outputs.cache-hit == 'true' && github.event_name != 'pull_request'
run: |
echo "Deleting existing cache for ${{ env.VERSIONKEY }}"
gh cache delete ${{ env.VERSIONKEY }} -R ${{ github.repository }}
shell: bash

- name: Cache versions
if: env.BUILD == 'true' && github.event_name != 'pull_request'
if: steps.rebuild_needed.outputs.build == 'true' && github.event_name != 'pull_request'
uses: actions/cache/save@v4
with:
key: ${{ env.VERSIONKEY }}
Expand Down

0 comments on commit 981069c

Please sign in to comment.