mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
hack: add license headers tool
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e218647127
commit
152b37e0f7
@ -7,7 +7,7 @@ group "pre-checkin" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group "validate" {
|
group "validate" {
|
||||||
targets = ["lint", "vendor-validate"]
|
targets = ["lint", "vendor-validate", "license-validate"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "build" {
|
target "build" {
|
||||||
@ -69,3 +69,15 @@ target "publish" {
|
|||||||
output = ["type=cacheonly"]
|
output = ["type=cacheonly"]
|
||||||
secret = ["id=NODE_AUTH_TOKEN,env=NODE_AUTH_TOKEN"]
|
secret = ["id=NODE_AUTH_TOKEN,env=NODE_AUTH_TOKEN"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target "license-validate" {
|
||||||
|
dockerfile = "./hack/dockerfiles/license.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "license-update" {
|
||||||
|
dockerfile = "./hack/dockerfiles/license.Dockerfile"
|
||||||
|
target = "update"
|
||||||
|
output = ["."]
|
||||||
|
}
|
||||||
|
33
hack/dockerfiles/license.Dockerfile
Normal file
33
hack/dockerfiles/license.Dockerfile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
ARG LICENSE_HOLDER="actions-toolkit authors"
|
||||||
|
ARG LICENSE_TYPE="apache"
|
||||||
|
ARG LICENSE_FILES=".*\(Dockerfile\|Makefile\|\.js\|\.ts\|\.hcl\|\.sh\)"
|
||||||
|
ARG ADDLICENSE_VERSION="v1.0.0"
|
||||||
|
|
||||||
|
FROM ghcr.io/google/addlicense:${ADDLICENSE_VERSION} AS addlicense
|
||||||
|
|
||||||
|
FROM alpine:3.17 AS base
|
||||||
|
WORKDIR /src
|
||||||
|
RUN apk add --no-cache cpio findutils git
|
||||||
|
|
||||||
|
FROM base AS set
|
||||||
|
ARG LICENSE_HOLDER
|
||||||
|
ARG LICENSE_TYPE
|
||||||
|
ARG LICENSE_FILES
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \
|
||||||
|
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | xargs addlicense -c "$LICENSE_HOLDER" -l "$LICENSE_TYPE" && \
|
||||||
|
mkdir /out && \
|
||||||
|
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | cpio -pdm /out
|
||||||
|
|
||||||
|
FROM scratch AS update
|
||||||
|
COPY --from=set /out /
|
||||||
|
|
||||||
|
FROM base AS validate
|
||||||
|
ARG LICENSE_HOLDER
|
||||||
|
ARG LICENSE_TYPE
|
||||||
|
ARG LICENSE_FILES
|
||||||
|
RUN --mount=type=bind,target=. \
|
||||||
|
--mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \
|
||||||
|
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | xargs addlicense -check -c "$LICENSE_HOLDER" -l "$LICENSE_TYPE"
|
Loading…
Reference in New Issue
Block a user