Skip to content

Commit

Permalink
Cache docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
ntse committed Nov 29, 2024
1 parent 50f2deb commit 51767b3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/container-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ jobs:
elif [ "${{ steps.aws_auth.outcome }}" == "success" ]; then
echo "uri=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ inputs.aws_region }}.amazonaws.com/${{ inputs.image_name }}:${{ inputs.tags }}" >> $GITHUB_OUTPUT
else
echo "uri=local/${{ inputs.image_name }}:${{ inputs.tags }}" >> $GITHUB_OUTPUT
echo "Warning: Neither AWS nor Azure have been authenticated. The image will be discarded at the end of this workflow."
fi
Expand All @@ -155,6 +156,8 @@ jobs:
platforms: ${{ inputs.docker_platforms }}
build-args: ${{ inputs.build_args }}
push: false
cache-from: type=gha
cache-to: type=gha,mode=max

# Optional: Run Unit Tests.
- name: Run Unit Tests
Expand All @@ -168,8 +171,13 @@ jobs:
exit 1
fi
echo "Running unit tests..."
${{ inputs.test_command }}
if ! ${{ inputs.test_command }}; then
echo "Unit tests failed."
exit 1
fi
- name: Push Docker Image
if: ${{ steps.unit_tests.outcome == 'success' && ( steps.az_auth.outcome != 'skipped' || steps.aws_auth.outcome != 'skipped' ) }}
if: >-
${{ steps.unit_tests.outcome == 'success' &&
(steps.az_auth.outcome == 'success' || steps.aws_auth.outcome == 'success') }}
run: docker image push ${{ steps.build_uri.outputs.uri }}

0 comments on commit 51767b3

Please sign in to comment.