diff --git a/docker/README.md b/docker/README.md index aefd183..0d1542a 100644 --- a/docker/README.md +++ b/docker/README.md @@ -20,6 +20,7 @@ Build a Docker image and push it to the Gitea container registry | `ARTIFACT_NAME` |

Name of the build artifact to download

| `false` | `dist` | | `ARTIFACT_PATH` |

Destination path for the downloaded artifact

| `false` | `dist` | | `TAG_LATEST` |

Also tag and push the image as latest

| `false` | `false` | +| `TAG_PREFIX` |

Optional prefix to prepend to IMAGE_TAG (e.g. 'dev' produces 'dev-<tag>'). Does not affect the latest tag.

| `false` | `""` | | `WORKING_DIRECTORY` |

Working directory for the Docker build

| `false` | `.` | diff --git a/docker/action.yml b/docker/action.yml index 44b632b..8680196 100644 --- a/docker/action.yml +++ b/docker/action.yml @@ -28,6 +28,9 @@ inputs: TAG_LATEST: description: "Also tag and push the image as latest" default: "false" + TAG_PREFIX: + description: "Optional prefix to prepend to IMAGE_TAG (e.g. 'dev' produces 'dev-'). Does not affect the latest tag." + default: "" WORKING_DIRECTORY: description: "Working directory for the Docker build" default: "." @@ -51,7 +54,11 @@ runs: - name: Docker Build and Push shell: sh run: | - TAGS="-t ${{ inputs.IMAGE_PATH }}:${{ inputs.IMAGE_TAG }}" + TAG="${{ inputs.IMAGE_TAG }}" + if [ -n "${{ inputs.TAG_PREFIX }}" ]; then + TAG="${{ inputs.TAG_PREFIX }}-${TAG}" + fi + TAGS="-t ${{ inputs.IMAGE_PATH }}:${TAG}" if [ "${{ inputs.TAG_LATEST }}" = "true" ]; then TAGS="$TAGS -t ${{ inputs.IMAGE_PATH }}:latest" fi