Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to omit default tags of built image #29

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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