@@ -97,39 +97,31 @@ jobs:
9797 path : ${{ inputs.image-destination-path }}
9898 if : inputs.disable-artifact-registry-as-image-store == false
9999
100- # Calculate a tag name
101- # If the image input is provided, use it as the tag
102- # If the workflow is triggered by a tag, use the tag as the tag
103- # Otherwise built GitOps compatible tags. Fallback to the branch name, commit hash, and timestamp. Those tags are sortable and unique.
100+ # Calculate the image tag with the same generator used in GitLab CI.
104101 - name : Set IMAGE_TAG
105- run : |
106- if [ "${IMAGE}" != "" ]; then
107- IMAGE_TAG="${IMAGE}"
108- elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
109- if [ "${IMAGE_SUFFIX}" != "" ]; then
110- IMAGE_TAG="ghcr.io/${{ github.repository }}/${IMAGE_SUFFIX}:${GITHUB_REF#refs/tags/}"
111- else
112- IMAGE_TAG="ghcr.io/${{ github.repository }}:${GITHUB_REF#refs/tags/}"
113- fi
114-
115- else
116- branch=${GITHUB_REF##*/}
117- sha=${GITHUB_SHA::8}
118- ts=$(date +%s)
119- if [ "${IMAGE_SUFFIX}" != "" ]; then
120- IMAGE_TAG="ghcr.io/${{ github.repository }}/${IMAGE_SUFFIX}:${branch}-${sha}-${ts}"
102+ uses : docker://ghcr.io/l3montree-dev/devguard/scanner:main
103+ with :
104+ args : >
105+ sh -c '
106+ if [ -n "$IMAGE" ]; then
107+ IMAGE_TAG="$IMAGE"
121108 else
122- IMAGE_TAG="ghcr.io/${{ github.repository }}:${branch}-${sha}-${ts}"
109+ if [ -n "$IMAGE_SUFFIX" ]; then
110+ IMAGE_PATH="ghcr.io/${GITHUB_REPOSITORY}/${IMAGE_SUFFIX}"
111+ else
112+ IMAGE_PATH="ghcr.io/${GITHUB_REPOSITORY}"
113+ fi
114+
115+ devguard-scanner generate-tag --imagePath="$IMAGE_PATH" --ref="$GITHUB_REF_NAME" > image-tag-env.txt
116+ IMAGE_TAG=$(grep '^IMAGE_TAG=' image-tag-env.txt | cut -d= -f2-)
123117 fi
124- fi
125-
126- IMAGE_TAG=$(echo "$IMAGE_TAG" | tr '[:upper:]' '[:lower:]')
127- echo "$IMAGE_TAG" > image-tag.txt
128118
129- # necessary for the kaniko job
130- echo "IMAGE_TAG=$(cat image-tag.txt)" >> $GITHUB_ENV
119+ IMAGE_TAG=$(echo "$IMAGE_TAG" | tr "[:upper:]" "[:lower:]")
120+ echo "$IMAGE_TAG" > image-tag.txt
121+ echo "IMAGE_TAG=$(cat image-tag.txt)" >> "$GITHUB_ENV"
122+ '
131123 env :
132- IMAGE_SUFFIX : ${{ inputs.image-suffix }}
124+ IMAGE_SUFFIX : ${{ inputs.image-suffix }}
133125 IMAGE : ${{ inputs.image }}
134126
135127 - name : Upload to container registry
0 commit comments