Skip to content

Commit 5b0c75d

Browse files
🐛 Fix annotations (#129)
Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com>
1 parent dd4e73d commit 5b0c75d

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

Taskfile.variables.yml

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ vars:
4141
DOCKER_NAME: '{{.DOCKER_ORG_NAME}}/{{.DOCKER_IMAGE}}'
4242
GITHUB_NAME: '{{.GITHUB_ORG_NAME}}/{{.GITHUB_REPO}}'
4343
GHRC_NAME: ghcr.io/{{.GITHUB_ORG_NAME}}/{{.GITHUB_REPO}}
44+
DEFAULT_BRANCH: master
45+
VERSION_FROM_ACTION_YML:
46+
sh: 'grep "image: docker://{{.DOCKER_NAME}}:" action.yml | cut -d ":" -f 4'
47+
AUTHOR_FROM_ACTION_YML:
48+
sh: |
49+
grep -e "^author:" action.yml | head -1 | awk -F": " '{print $2}'
50+
NAME_FROM_ACTION_YML:
51+
sh: |
52+
grep -e "^name:" action.yml | head -1 | awk -F": " '{print $2}'
53+
DESCRIPTION_FROM_ACTION_YML:
54+
sh: |
55+
grep -e "^description:" action.yml | head -1 | awk -F": " '{print $2}'
4456
LABEL_AUTHOR: '{{.LABEL_AUTHOR | default .AUTHOR_FROM_ACTION_YML}}'
4557
LABEL_NAME: '{{.LABEL_NAME | default .NAME_FROM_ACTION_YML}}'
4658
LABEL_DESCRIPTION: '{{.LABEL_DESCRIPTION | default .DESCRIPTION_FROM_ACTION_YML}}'
@@ -52,23 +64,6 @@ vars:
5264
LABEL_VENDOR: '{{.LABEL_VENDOR | default "DevOps-Infra"}}'
5365
LABEL_LICENSE: '{{.LABEL_LICENSE | default "MIT"}}'
5466

55-
# Action metadata
56-
AUTHOR_FROM_ACTION_YML:
57-
sh: |
58-
awk -F":" '/^author:/ { $1=""; sub(/^[: ]+/, ""); gsub(/^\"|\"$/,"",$0); print $0; exit }' action.yml || true
59-
NAME_FROM_ACTION_YML:
60-
sh: |
61-
awk -F":" '/^name:/ { $1=""; sub(/^[: ]+/, ""); gsub(/^\"|\"$/,"",$0); print $0; exit }' action.yml || true
62-
DESCRIPTION_FROM_ACTION_YML:
63-
sh: |
64-
awk -F":" '/^description:/ { $1=""; sub(/^[: ]+/, ""); gsub(/^\"|\"$/,"",$0); print $0; exit }' action.yml || true
65-
VERSION_FROM_ACTION_YML:
66-
sh: 'grep "image: docker://{{.DOCKER_NAME}}:" action.yml | cut -d ":" -f 4'
67-
MAJOR_FROM_ACTION_YML:
68-
sh: echo "{{.VERSION_FROM_ACTION_YML}}" | awk -F\. '{print $1}'
69-
MINOR_FROM_ACTION_YML:
70-
sh: echo "{{.VERSION_FROM_ACTION_YML}}" | awk -F\. '{print $1"."$2}'
71-
7267
# Build context
7368
CONTEXT: '{{.CONTEXT | default "."}}'
7469
DOCKERFILE: '{{.DOCKERFILE | default "Dockerfile"}}'
@@ -115,9 +110,12 @@ vars:
115110
sh: echo $(( {{.MINOR}} + 1 ))
116111
NEXT_MAJOR:
117112
sh: echo $(( {{.MAJOR}} + 1 ))
113+
MAJOR_FROM_ACTION_YML:
114+
sh: echo "{{.VERSION_FROM_ACTION_YML}}" | awk -F\. '{print $1}'
115+
MINOR_FROM_ACTION_YML:
116+
sh: echo "{{.VERSION_FROM_ACTION_YML}}" | awk -F\. '{print $1"."$2}'
118117

119118
# Git metadata
120-
DEFAULT_BRANCH: master
121119
GIT_SHA:
122120
sh: git rev-parse HEAD 2>/dev/null || echo 0000000000000000000000000000000000000000
123121
GIT_SHORT_SHA:
@@ -133,6 +131,27 @@ vars:
133131
# Labels for http://label-schema.org/rc1/#build-time-labels
134132
# And for https://github.com/opencontainers/image-spec/blob/master/annotations.md
135133
ANNOTATIONS: >-
134+
--annotation index:org.label-schema.schema-version="1.0"
135+
--annotation index:org.label-schema.build-date="{{.BUILD_DATE}}"
136+
--annotation index:org.label-schema.name="{{.LABEL_NAME}}"
137+
--annotation index:org.label-schema.description="{{.LABEL_DESCRIPTION}}"
138+
--annotation index:org.label-schema.usage="{{.LABEL_DOCS_URL}}"
139+
--annotation index:org.label-schema.url="{{.LABEL_HOMEPAGE}}"
140+
--annotation index:org.label-schema.vcs-url="{{.LABEL_REPO_URL}}"
141+
--annotation index:org.label-schema.vcs-ref="{{.GIT_SHA}}"
142+
--annotation index:org.label-schema.vendor="{{.LABEL_VENDOR}}"
143+
--annotation index:org.label-schema.version="{{.VERSION_FULL}}{{.VERSION_SUFFIX}}"
144+
--annotation index:org.opencontainers.image.created="{{.BUILD_DATE}}"
145+
--annotation index:org.opencontainers.image.authors="{{.LABEL_AUTHOR}}"
146+
--annotation index:org.opencontainers.image.url="{{.LABEL_HOMEPAGE}}"
147+
--annotation index:org.opencontainers.image.documentation="{{.LABEL_DOCS_URL}}"
148+
--annotation index:org.opencontainers.image.source="{{.LABEL_REPO_URL}}"
149+
--annotation index:org.opencontainers.image.version="{{.VERSION_FULL}}{{.VERSION_SUFFIX}}"
150+
--annotation index:org.opencontainers.image.revision="{{.GIT_SHA}}"
151+
--annotation index:org.opencontainers.image.vendor="{{.LABEL_VENDOR}}"
152+
--annotation index:org.opencontainers.image.licenses="{{.LABEL_LICENSE}}"
153+
--annotation index:org.opencontainers.image.title="{{.LABEL_NAME}}"
154+
--annotation index:org.opencontainers.image.description="{{.LABEL_DESCRIPTION}}"
136155
--annotation manifest:org.label-schema.schema-version="1.0"
137156
--annotation manifest:org.label-schema.build-date="{{.BUILD_DATE}}"
138157
--annotation manifest:org.label-schema.name="{{.LABEL_NAME}}"

0 commit comments

Comments
 (0)