From 52aa8fa7b1ba837248197724704a6988014c16a9 Mon Sep 17 00:00:00 2001 From: linguist <22963968+lowlighter@users.noreply.github.com> Date: Thu, 31 Dec 2020 19:18:16 +0100 Subject: [PATCH] Use version from package.json for docker images --- action.yml | 23 ++++++++++++++--------- source/app/action/index.mjs | 1 - 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index 267867db..da0be3c1 100644 --- a/action.yml +++ b/action.yml @@ -356,23 +356,28 @@ branding: color: gray-dark # The action will parse its name to check if it's the official action or if it's a forked one -# On the official action, it'll use the docker image published on GitHub registry, allowing faster runs +# On the official action, it'll use the docker image published on GitHub registry when using a released version, allowing faster runs # On a forked action, it'll rebuild the docker image from Dockerfile runs: using: composite steps: - run: | - # Parse source repository and ref + # Parse source repository and version cd $METRICS_ACTION_PATH METRICS_SOURCE=$(echo $METRICS_ACTION | sed -E 's/metrics.*?$//g') - METRICS_REF=$(echo $METRICS_ACTION | sed -E 's/^.*metrics//g') - echo "Running on $METRICS_SOURCE/metrics@$METRICS_REF" + METRICS_VERSION=v$(grep -Po '(?<="version": ")\d+[.]\d+(?=[.]0")' package.json) - # If using official action, use docker image from GitHub registry - if [[ $METRICS_SOURCE == "lowlighter-test-forks" ]]; then - echo "Will use docker image from GitHub registry" - METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_REF - # On forked actions, rebuild the docker image instead + # If using official action, check if a released version is used + if [[ $METRICS_SOURCE == "lowlighter" ]]; then + if [[ $METRICS_VERSION ]]; then + echo "Using released version $METRICS_VERSION, will pull docker image from GitHub registry" + METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_VERSION + else + echo "This is an unreleased version, rebuilding docker image from Dockerfile" + docker build -t metrics:unreleased . + METRICS_IMAGE=metrics:unreleased + fi + # On forked actions, always rebuild the docker image else echo "This is a forked version, rebuilding docker image from Dockerfile" docker build -t metrics:forked . diff --git a/source/app/action/index.mjs b/source/app/action/index.mjs index a15fdd29..826e21f3 100644 --- a/source/app/action/index.mjs +++ b/source/app/action/index.mjs @@ -211,7 +211,6 @@ //Render metrics const rendered = await metrics({login:user, q, dflags}, {graphql, rest, plugins, conf, die, verify}, {Plugins, Templates}) info("Rendering", "complete") - console.log(`Render │ complete`) //Commit to repository const dryrun = input.bool("dryrun")