image action updates
This commit is contained in:
@@ -6,6 +6,15 @@ outputs:
|
||||
tag:
|
||||
description: The image tag
|
||||
value: ${{ steps.get_tag.outputs.tag }}
|
||||
is_semver:
|
||||
description: Whether the tag is a semantic version
|
||||
value: ${{ steps.check_semver.outputs.is_semver }}
|
||||
|
||||
inputs:
|
||||
tag:
|
||||
description: The image tag. If this is set it will return the tag as is.
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
@@ -14,7 +23,9 @@ runs:
|
||||
id: get_tag
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${{ github.ref_type }}" == "tag" ]]; then
|
||||
if [[ -n "${{ inputs.tag }}" ]]; then
|
||||
tag="${{ inputs.tag }}"
|
||||
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
|
||||
if [[ "${{ github.ref_name }}" == infra-*-* ]]; then
|
||||
env=$(echo ${{ github.ref_name }} | cut -d- -f2)
|
||||
sha=$(echo ${{ github.sha }} | head -c7)
|
||||
@@ -36,3 +47,31 @@ runs:
|
||||
exit 1
|
||||
fi
|
||||
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: 🔍 Check for validity
|
||||
id: check_validity
|
||||
shell: bash
|
||||
env:
|
||||
tag: ${{ steps.get_tag.outputs.tag }}
|
||||
run: |
|
||||
if [[ "${tag}" =~ ^[a-z0-9]+([._-][a-z0-9]+)*$ ]]; then
|
||||
echo "Tag is valid: ${tag}"
|
||||
else
|
||||
echo "Tag is not valid: ${tag}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: 🆚 Check for semver
|
||||
id: check_semver
|
||||
shell: bash
|
||||
env:
|
||||
tag: ${{ steps.get_tag.outputs.tag }}
|
||||
run: |
|
||||
if [[ "${tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+)?$ ]]; then
|
||||
echo "Tag is a semantic version: ${tag}"
|
||||
is_semver=true
|
||||
else
|
||||
echo "Tag is not a semantic version: ${tag}"
|
||||
is_semver=false
|
||||
fi
|
||||
echo "is_semver=${is_semver}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
Reference in New Issue
Block a user