Skip to content

Commit d947792

Browse files
authored
Merge pull request #19569 from dvdksn/fix-upstream-vendor
build: create makefile for vendoring
2 parents 53c2a29 + 1d65052 commit d947792

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ ADD .htmltest.yml .htmltest.yml
4949
RUN htmltest
5050

5151
FROM build-base as update-modules
52-
ARG MODULE="-u"
53-
RUN hugo mod get ${MODULE}
52+
ARG MODULE
53+
RUN if [ -n "$MODULE" ]; then \
54+
hugo mod get ${MODULE}; \
55+
else \
56+
echo "no module set"; \
57+
fi
5458
RUN hugo mod vendor
5559

5660
FROM scratch as vendor

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.PHONY: vendor
2+
vendor: ## vendor hugo modules
3+
./scripts/vendor.sh

docker-bake.hcl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,14 @@ target "aws-cloudfront-update" {
141141
output = ["type=cacheonly"]
142142
}
143143

144+
variable "VENDOR_MODULE" {
145+
default = null
146+
}
147+
144148
target "vendor" {
145149
target = "vendor"
146150
args = {
147-
MODULE = null
151+
MODULE = VENDOR_MODULE
148152
}
149153
output = ["."]
150154
}

scripts/vendor.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu -o pipefail
4+
5+
output=$(mktemp -d -t hugo-vendor-output.XXXXXXXXXX)
6+
7+
function clean {
8+
rm -rf "$output"
9+
}
10+
11+
trap clean EXIT
12+
13+
docker buildx bake vendor \
14+
"--set=*.output=type=local,dest=${output}"
15+
rm -r _vendor
16+
cp -R $output/* .

0 commit comments

Comments
 (0)