Skip to content

Commit

Permalink
Enable specifying the target repository (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkuchenb authored Aug 13, 2024
1 parent e5145ec commit dbffab1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ inputs:
description: "The namespace used to publish to the registry."
required: true
default: ghga
dockerhub_repository:
description: "The Docker Hub repository to publish to. Defaults to git repository name."
required: false
default: ""
working_directory:
description: "Directory which contains Dockerfile and project configuration files."
default: "."
Expand Down Expand Up @@ -118,14 +122,24 @@ runs:
echo "tag_suffix=" >> $GITHUB_OUTPUT
fi
- name: Infer target repository name
shell: bash
id: infer_repository
run: |
if [ -z "${{ inputs.dockerhub_repository }}" ]; then
echo "dockerhub_repository=${{ github.event.repository.name }}" >> $GITHUB_OUTPUT
else
echo "dockerhub_repository=${{ inputs.dockerhub_repository }}" >> $GITHUB_OUTPUT
fi
- uses: docker/build-push-action@v5
name: Build and push
id: docker_build
with:
push: true
platforms: "${{ inputs.dockerhub_platforms }}"
file: "${{ inputs.working_directory }}/Dockerfile${{ steps.get_suffixes.outputs.dockerfile_suffix }}"
tags: "${{ inputs.dockerhub_namespace }}/${{ github.event.repository.name }}:${{ inputs.tag }}${{ steps.get_suffixes.outputs.tag_suffix }}"
tags: "${{ inputs.dockerhub_namespace }}/${{ steps.infer_repository.outputs.dockerhub_repository }}:${{ inputs.tag }}${{ steps.get_suffixes.outputs.tag_suffix }}"
context: "${{ inputs.working_directory }}"

- name: Run Trivy vulnerability scanner
Expand Down

0 comments on commit dbffab1

Please sign in to comment.