Skip to content

Commit

Permalink
Add possibility to omit default tags of built image
Browse files Browse the repository at this point in the history
  • Loading branch information
zmiklank committed Sep 27, 2023
1 parent 5aba42a commit 7e00370
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ registry/registry_namespace/image_name
|------------|-------------|---------------|
| `image_name` | Name of the built image. | **required** |
| `tag` | Tag of the built image. | "" |
| `use_default_tags` | Add default tags to image - SHA, latest, current date | true |
| `archs` | Label the image with this architecture. For multiple architectures, seperate them by a comma. | amd64 |
| `dockerfile` | Dockerfile and its relative path to build the image. | Dockerfile |
| `docker_context` | Docker build context. | . |
Expand Down
15 changes: 14 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ inputs:
description: 'Docker build context'
required: false
default: '.'
use_default_tags:
description: 'Tags built image with default tags - SHA, latest, current date'
required: false
default: 'true'

runs:
using: "composite"
Expand Down Expand Up @@ -85,6 +89,15 @@ runs:
files: "${{ inputs.dockerfile }}"
fail: true # fails the Action if Dockerfile is missing

- name: Prepare tags
shell: bash
id: tags
run: |
tags="${{ inputs.tag }}"
if [ ${{ inputs.use_default_tags }} == true ]; then
tags="$tags latest ${{ steps.vars.outputs.cur_date }} ${{ github.sha }}"
fi
echo "tags=$tags" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
if: inputs.archs != 'amd64'
Expand All @@ -100,7 +113,7 @@ runs:
image: ${{ inputs.image_name}}
archs: ${{ inputs.archs }}
context: ${{ inputs.docker_context }}
tags: latest ${{ inputs.tag }} ${{ steps.vars.outputs.cur_date }} ${{ github.sha }}
tags: ${{ steps.tags.outputs.tags }}

- name: Push image to Quay.io/${{ inputs.registry_namespace }} namespace
if: steps.check_exclude_file.outputs.files_exists == 'false'
Expand Down

0 comments on commit 7e00370

Please sign in to comment.