Use sanitized github.ref
This commit is contained in:
@@ -25,6 +25,30 @@ jobs:
|
||||
# echo "MY_LOWER=$lower_value" >> $GITHUB_ENV
|
||||
# If you want to use it as an output of this step:
|
||||
echo "lowercase=$lower_value" >> $GITHUB_OUTPUT
|
||||
- name: Convert ref to buildx safe value
|
||||
id: docker_tag_from_ref
|
||||
shell: bash
|
||||
run: |
|
||||
# Grab the raw ref
|
||||
REF="${{ github.ref }}"
|
||||
|
||||
# Strip the "refs/*/" prefix (refs/heads/, refs/tags/…)
|
||||
TAG=${REF#refs/*/}
|
||||
|
||||
# Replace characters that Docker tags disallow
|
||||
# * "/" → "-"
|
||||
# * ":" → "-"
|
||||
# * Any other non‑alphanumeric / . / _ / - → "-"
|
||||
TAG=${TAG//\//-}
|
||||
TAG=${TAG//:/-}
|
||||
TAG=${TAG//[^a-zA-Z0-9._-]/-}
|
||||
|
||||
# (Optional) force lower‑case – Docker tags are case‑sensitive,
|
||||
# but many people prefer lower‑case
|
||||
TAG=${TAG,,}
|
||||
|
||||
# Export to the action's output
|
||||
echo "docker-tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
# ------------------------------------------------------------------
|
||||
# 1. Checkout repository
|
||||
# ------------------------------------------------------------------
|
||||
@@ -70,7 +94,7 @@ jobs:
|
||||
push: false
|
||||
tags: |
|
||||
${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ github.sha }}
|
||||
${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ github.ref_name }}
|
||||
${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ steps.docker_tag_from_ref.outputs.docker-tag }}
|
||||
${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:latest
|
||||
build-args: |
|
||||
# Add any build args here
|
||||
@@ -89,7 +113,7 @@ jobs:
|
||||
push: true
|
||||
tags: |
|
||||
${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ github.sha }}
|
||||
${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ github.ref_name }}
|
||||
${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ steps.docker_tag_from_ref.outputs.docker-tag }}
|
||||
${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:latest
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
@@ -108,5 +132,5 @@ jobs:
|
||||
run: |
|
||||
echo "Pushed image tags:"
|
||||
echo "- ${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ github.sha }}"
|
||||
echo "- ${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ github.ref_name }}"
|
||||
echo "- ${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:${{ steps.docker_tag_from_ref.outputs.docker-tag }}"
|
||||
echo "- ${{ vars.REGISTRY_HOST }}/${{ steps.github_repository_to_lowercase.outputs.lowercase }}:latest"
|
||||
Reference in New Issue
Block a user