From cc9245a043a78d66148e337eb6add15e7a8569a8 Mon Sep 17 00:00:00 2001 From: Sven Lechner Date: Fri, 30 Aug 2019 19:49:35 +0200 Subject: [PATCH] feat(docker): add ability to always download latest or specific docker version --- Dockerfile | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index da160b3..e66d6da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,11 +9,26 @@ LABEL "repository"="https://github.com/peaceiris/actions-hugo" LABEL "homepage"="https://github.com/peaceiris/actions-hugo" LABEL "maintainer"="peaceiris" -ENV HUGO_VERSION='0.57.2' -ENV HUGO_NAME="hugo_extended_${HUGO_VERSION}_Linux-64bit" -ENV HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_NAME}.tar.gz" -RUN wget "${HUGO_URL}" && \ - tar -zxvf "${HUGO_NAME}.tar.gz" && \ +ARG HUGO_VERSION="auto" +RUN echo "Hugo version: ${HUGO_VERSION}" + +RUN if [ "$HUGO_VERSION" = "auto" ]; then \ + echo "Using automated version detection" && \ + curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | \ + grep browser_download_url | \ + cut -d '"' -f 4 | \ + grep -e 'hugo_extended_.*_Linux.*\.tar\.gz' | \ + xargs curl -fsSL -O; fi + +RUN if [ ! "$HUGO_VERSION" = "auto" ]; then \ + echo "Using fixed version $HUGO_VERSION" && \ + curl "https://api.github.com/repos/gohugoio/hugo/releases/tags/v${HUGO_VERSION}" | \ + grep browser_download_url | \ + cut -d '"' -f 4 | \ + grep -e 'hugo_extended_.*_Linux.*\.tar\.gz' | \ + xargs curl -fsSL -O; fi + +RUN cat *.gz | tar -xzvf - -i && \ mv ./hugo /go/bin/ ENTRYPOINT [ "/go/bin/hugo" ]