Skip to content

Commit

Permalink
feat: added caching outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
piximos committed Apr 19, 2024
1 parent 8930120 commit 9572f49
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
required: false
description: the name of the docker image to configure
default: ''
cache-registry-name:
required: false
description: the name of the docker registry to use for caching
default: ''
ecr-login:
required: false
description: 'Set to false to not login to ECR'
Expand Down Expand Up @@ -56,6 +60,12 @@ outputs:
docker-tags:
description: 'The tags of the docker image'
value: '${{ steps.meta.outputs.tags }}'
input-cache-repo:
description: 'The tags of the docker image'
value: '${{ steps.caching-config.input-cache-repo }}'
output-cache-repo:
description: 'The tags of the docker image'
value: '${{ steps.caching-config.output-cache-repo }}'


runs:
Expand Down Expand Up @@ -99,6 +109,23 @@ runs:
echo "ecr-repo-name=${{inputs.aws-account-id}}.dkr.ecr.${{ inputs.aws-region }}.amazonaws.com/image/${{ inputs.ecr-repo-name }}" >>"${GITHUB_OUTPUT}"
fi
- name: Caching Config
id: caching-config
shell: bash
if: inputs.run-tag-generator == 'true' && inputs.cache-registry-name != ''
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "$(gh pr view "${{ github.event.pull_request.number }}" --json commits -q '.commits | length' || true)" == "1" ]]; then
echo "input-cache-repo=${{ inputs.cache-registry-name }}/${{ inputs.ecr-repo-name }}:cache" >>"${GITHUB_OUTPUT}"
else
echo "input-cache-repo=${{ inputs.cache-registry-name }}/${{ inputs.ecr-repo-name }}:pr${{ github.event.pull_request.number }}-cache" >>"${GITHUB_OUTPUT}"
fi
echo "output-cache-repo=${{ inputs.cache-registry-name }}/${{ inputs.ecr-repo-name }}:pr${{ github.event.pull_request.number }}-cache" >>"${GITHUB_OUTPUT}"
else
echo "input-cache-repo=${{ inputs.cache-registry-name }}/${{ inputs.ecr-repo-name }}:cache" >>"${GITHUB_OUTPUT}"
echo "output-cache-repo=${{ inputs.cache-registry-name }}/${{ inputs.ecr-repo-name }}:cache" >>"${GITHUB_OUTPUT}"
fi
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand Down

0 comments on commit 9572f49

Please sign in to comment.