| 
 | 1 | +name: 'Create GlueOps Image Tags'  | 
 | 2 | +description: 'Creates tags for docker images used by the GlueOps platform'  | 
 | 3 | + | 
 | 4 | +outputs:  | 
 | 5 | +  tags_csv:  | 
 | 6 | +    description: 'Comma-separated list of GlueOps image tags'  | 
 | 7 | +    value: ${{ steps.create-tags.outputs.tags }}  | 
 | 8 | +  clean_target_ref:  | 
 | 9 | +    description: 'Target reference with invalid tag characters removed'  | 
 | 10 | +    value: ${{ steps.create-tags.outputs.target-ref}}  | 
 | 11 | +  target_ref_type:  | 
 | 12 | +    description: 'Type of Target ref, as ["branch", "pull_request", "tag", "unknown"]'  | 
 | 13 | +    value: ${{ steps.create-tags.outputs.target-ref-type }}  | 
 | 14 | + | 
 | 15 | +runs:  | 
 | 16 | +  using: "composite"  | 
 | 17 | +  steps:  | 
 | 18 | +    - name: Create Tags  | 
 | 19 | +      id: create-tags  | 
 | 20 | +      shell: bash  | 
 | 21 | +      run: |  | 
 | 22 | +        echo "::group::determine ref"  | 
 | 23 | +        if [[ $GITHUB_REF == refs/heads/* ]]; then  | 
 | 24 | +          REF_TYPE=branch  | 
 | 25 | +          TARGET_REF=${GITHUB_REF#refs/heads/}  | 
 | 26 | +        elif [[ $GITHUB_REF == refs/tags/* ]]; then  | 
 | 27 | +          REF_TYPE=tag  | 
 | 28 | +          TARGET_REF=${GITHUB_REF#refs/tags/}  | 
 | 29 | +        elif [[ $GITHUB_REF == refs/pull/* ]]; then  | 
 | 30 | +          REF_TYPE=pull_request  | 
 | 31 | +          TARGET_REF=$GITHUB_SHA  | 
 | 32 | +        else  | 
 | 33 | +          REF_TYPE=unknown  | 
 | 34 | +        fi  | 
 | 35 | +        echo "target-ref-type=$TARGET_REF" >> $GITHUB_OUTPUT  | 
 | 36 | +
  | 
 | 37 | +        echo "::endgroup::"  | 
 | 38 | +        # Create default tags  | 
 | 39 | +        SHA="${{ github.sha }}"  | 
 | 40 | +        SHORT_SHA="${SHA:0:7}"  | 
 | 41 | +
  | 
 | 42 | +        # Remove invalid tag characters from TARGET_REF  | 
 | 43 | +        TARGET_REF="${TARGET_REF#refs/tags/}"   | 
 | 44 | +        TARGET_REF="${TARGET_REF#refs/heads/}"  | 
 | 45 | +        TARGET_REF=${TARGET_REF////-}      # Replace slashes with hyphens  | 
 | 46 | +        TARGET_REF=${TARGET_REF//[^a-zA-Z0-9_.-]/_}   # Replace invalid characters with underscores  | 
 | 47 | +        TARGET_REF=${TARGET_REF// /_}      # Replace whitespaces with underscores  | 
 | 48 | +        TARGET_REF=${TARGET_REF,,}         # Convert to lowercase  | 
 | 49 | +        echo "target-ref=$TARGET_REF" >> $GITHUB_OUTPUT  | 
 | 50 | +
  | 
 | 51 | +
  | 
 | 52 | +        # Array of tags to generate  | 
 | 53 | +        TAGS_ARRAY=(  | 
 | 54 | +          "${TARGET_REF}"  | 
 | 55 | +          "${SHORT_SHA}"  | 
 | 56 | +          "${SHA}"  | 
 | 57 | +        )  | 
 | 58 | +          | 
 | 59 | +        IFS=','  | 
 | 60 | +        TAGS=${TAGS_ARRAY[*]}  | 
 | 61 | +        echo "Computed tags: $TAGS"  | 
 | 62 | +        echo "tags=$TAGS" >> $GITHUB_OUTPUT  | 
0 commit comments