Use version from package.json for docker images

This commit is contained in:
linguist
2020-12-31 19:18:16 +01:00
parent 19b3f1490c
commit 52aa8fa7b1
2 changed files with 14 additions and 10 deletions

View File

@@ -356,23 +356,28 @@ branding:
color: gray-dark color: gray-dark
# The action will parse its name to check if it's the official action or if it's a forked one # 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 # On a forked action, it'll rebuild the docker image from Dockerfile
runs: runs:
using: composite using: composite
steps: steps:
- run: | - run: |
# Parse source repository and ref # Parse source repository and version
cd $METRICS_ACTION_PATH cd $METRICS_ACTION_PATH
METRICS_SOURCE=$(echo $METRICS_ACTION | sed -E 's/metrics.*?$//g') METRICS_SOURCE=$(echo $METRICS_ACTION | sed -E 's/metrics.*?$//g')
METRICS_REF=$(echo $METRICS_ACTION | sed -E 's/^.*metrics//g') METRICS_VERSION=v$(grep -Po '(?<="version": ")\d+[.]\d+(?=[.]0")' package.json)
echo "Running on $METRICS_SOURCE/metrics@$METRICS_REF"
# If using official action, use docker image from GitHub registry # If using official action, check if a released version is used
if [[ $METRICS_SOURCE == "lowlighter-test-forks" ]]; then if [[ $METRICS_SOURCE == "lowlighter" ]]; then
echo "Will use docker image from GitHub registry" if [[ $METRICS_VERSION ]]; then
METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_REF echo "Using released version $METRICS_VERSION, will pull docker image from GitHub registry"
# On forked actions, rebuild the docker image instead 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 else
echo "This is a forked version, rebuilding docker image from Dockerfile" echo "This is a forked version, rebuilding docker image from Dockerfile"
docker build -t metrics:forked . docker build -t metrics:forked .

View File

@@ -211,7 +211,6 @@
//Render metrics //Render metrics
const rendered = await metrics({login:user, q, dflags}, {graphql, rest, plugins, conf, die, verify}, {Plugins, Templates}) const rendered = await metrics({login:user, q, dflags}, {graphql, rest, plugins, conf, die, verify}, {Plugins, Templates})
info("Rendering", "complete") info("Rendering", "complete")
console.log(`Render │ complete`)
//Commit to repository //Commit to repository
const dryrun = input.bool("dryrun") const dryrun = input.bool("dryrun")