Skip to content

Commit

Permalink
Not trusting the cache...
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Jan 15, 2025
1 parent 77cc612 commit dc25742
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions twostep-container-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,9 @@ runs:
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Build and push
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@v6
with:
no-cache: true
push: ${{ inputs.push-image-1 }}
tags: |
${{ inputs.registry }}${{ inputs.image }}:dependencies-${{ steps.image-tag.outputs.tag }}
file: ${{ inputs.container-file-1 }}
build-args: ${{ inputs.build-args-1 }}
labels: |
${{ inputs.build-labels-1 }}
TWO_STEP_BUILD_CACHE_HASH=${{ inputs.first-step-cache-key }}
- name: Pulling the image
if: steps.cache.outputs.cache-hit == 'true'
id: pull-image
shell: bash
run: |
# Ensuring we can pull the image, if cache exists
Expand All @@ -162,10 +149,31 @@ runs:
${{ github.sha }}_cache_hash
if [ "$(cat ${{ github.sha }}_cache_hash)" != "${{ inputs.first-step-cache-key }}" ]; then
echo "Cache hash does not match."
exit 1
echo "Cache hash does not match: Please report this to the "
echo "ongoing issue at "
echo "https://github.com/CDCgov/cfa-actions/issues/10."
echo "Rebuilding the image..."
echo "image-found=false" >> $GITHUB_OUTPUT
else
echo "Cache hash matches (all good!)."
echo "image-found=true" >> $GITHUB_OUTPUT
fi
- name: Build and push
if: steps.cache.outputs.cache-hit != 'true' || steps.pull-image.outputs.image-found != 'true'
uses: docker/build-push-action@v6
with:
no-cache: true
push: ${{ inputs.push-image-1 }}
tags: |
${{ inputs.registry }}${{ inputs.image }}:dependencies-${{ steps.image-tag.outputs.tag }}
file: ${{ inputs.container-file-1 }}
build-args: ${{ inputs.build-args-1 }}
labels: |
${{ inputs.build-labels-1 }}
TWO_STEP_BUILD_CACHE_HASH=${{ inputs.first-step-cache-key }}
- name: Build and push the main image
id: build_and_push_model_image
Expand Down

0 comments on commit dc25742

Please sign in to comment.