Auto-regenerate files
This commit is contained in:
48
action.yml
48
action.yml
@@ -69,6 +69,11 @@ inputs:
|
|||||||
description: Rendered metrics output path
|
description: Rendered metrics output path
|
||||||
default: github-metrics.svg
|
default: github-metrics.svg
|
||||||
|
|
||||||
|
# Output action
|
||||||
|
output_action:
|
||||||
|
description: Output action
|
||||||
|
default: commit
|
||||||
|
|
||||||
# Optimize SVG image to reduce its filesize
|
# Optimize SVG image to reduce its filesize
|
||||||
# Some templates may not support this option
|
# Some templates may not support this option
|
||||||
optimize:
|
optimize:
|
||||||
@@ -167,7 +172,8 @@ inputs:
|
|||||||
description: Debug flags
|
description: Debug flags
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
# Dry-run mode (perform generation without pushing it)
|
# Dry-run mode (perform generation without output)
|
||||||
|
# Unlike "output_action" set to "none", output file won't be available in "/metrics_renders"
|
||||||
dryrun:
|
dryrun:
|
||||||
description: Enable dry-run
|
description: Enable dry-run
|
||||||
default: no
|
default: no
|
||||||
@@ -182,11 +188,12 @@ inputs:
|
|||||||
description: Use mocked data instead of live APIs
|
description: Use mocked data instead of live APIs
|
||||||
default: no
|
default: no
|
||||||
|
|
||||||
# Use a pre-built image from GitHub registry (experimental)
|
# Use a pre-built image from GitHub registry when using unreleased versions of "lowlighter/metrics"
|
||||||
|
# This option has no effect on forks (images will always be rebuilt from Dockerfile)
|
||||||
# See https://github.com/users/lowlighter/packages/container/package/metrics for more information
|
# See https://github.com/users/lowlighter/packages/container/package/metrics for more information
|
||||||
use_prebuilt_image:
|
use_prebuilt_image:
|
||||||
description: Use pre-built image from GitHub registry
|
description: Use pre-built image from GitHub registry
|
||||||
default: ""
|
default: yes
|
||||||
|
|
||||||
# ====================================================================================
|
# ====================================================================================
|
||||||
# 📰 Recent activity
|
# 📰 Recent activity
|
||||||
@@ -846,13 +853,19 @@ runs:
|
|||||||
steps:
|
steps:
|
||||||
- run: |
|
- run: |
|
||||||
# Create environment file from inputs and GitHub variables
|
# Create environment file from inputs and GitHub variables
|
||||||
|
echo "::group::Metrics docker image setup"
|
||||||
cd $METRICS_ACTION_PATH
|
cd $METRICS_ACTION_PATH
|
||||||
touch .env
|
touch .env
|
||||||
for INPUT in $(echo $INPUTS | jq -r 'to_entries|map("INPUT_\(.key|ascii_upcase)=\(.value|@uri)")|.[]'); do
|
for INPUT in $(echo $INPUTS | jq -r 'to_entries|map("INPUT_\(.key|ascii_upcase)=\(.value|@uri)")|.[]'); do
|
||||||
echo $INPUT >> .env
|
echo $INPUT >> .env
|
||||||
done
|
done
|
||||||
env | grep -E '^(GITHUB|ACTIONS|CI)' >> .env
|
env | grep -E '^(GITHUB|ACTIONS|CI)' >> .env
|
||||||
echo "Environment variable: loaded"
|
echo "Environment variables: loaded"
|
||||||
|
|
||||||
|
# Renders output folder
|
||||||
|
METRICS_RENDERS="/metrics_renders"
|
||||||
|
sudo mkdir -p $METRICS_RENDERS
|
||||||
|
echo "Renders output folder: $METRICS_RENDERS"
|
||||||
|
|
||||||
# Source repository (picked from action name)
|
# Source repository (picked from action name)
|
||||||
METRICS_SOURCE=$(echo $METRICS_ACTION | sed -E 's/metrics.*?$//g')
|
METRICS_SOURCE=$(echo $METRICS_ACTION | sed -E 's/metrics.*?$//g')
|
||||||
@@ -864,20 +877,11 @@ runs:
|
|||||||
|
|
||||||
# Image tag (extracted from version or from env)
|
# Image tag (extracted from version or from env)
|
||||||
METRICS_TAG=v$(echo $METRICS_VERSION | sed -r 's/^([0-9]+[.][0-9]+).*/\1/')
|
METRICS_TAG=v$(echo $METRICS_VERSION | sed -r 's/^([0-9]+[.][0-9]+).*/\1/')
|
||||||
if [[ $METRICS_USE_PREBUILT_IMAGE ]]; then
|
|
||||||
METRICS_TAG=$METRICS_USE_PREBUILT_IMAGE
|
|
||||||
echo "Pre-built image: yes"
|
|
||||||
fi
|
|
||||||
echo "Image tag: $METRICS_TAG"
|
echo "Image tag: $METRICS_TAG"
|
||||||
|
|
||||||
# Image name
|
# Image name
|
||||||
# Pre-built image
|
|
||||||
if [[ $METRICS_USE_PREBUILT_IMAGE ]]; then
|
|
||||||
echo "Using pre-built version $METRICS_TAG, will pull docker image from GitHub registry"
|
|
||||||
METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_TAG
|
|
||||||
docker image pull $METRICS_IMAGE > /dev/null
|
|
||||||
# Official action
|
# Official action
|
||||||
elif [[ $METRICS_SOURCE == "lowlighter" ]]; then
|
if [[ $METRICS_SOURCE == "lowlighter" ]]; then
|
||||||
# Is released version
|
# Is released version
|
||||||
set +e
|
set +e
|
||||||
METRICS_IS_RELEASED=$(expr $(expr match $METRICS_VERSION .*-beta) == 0)
|
METRICS_IS_RELEASED=$(expr $(expr match $METRICS_VERSION .*-beta) == 0)
|
||||||
@@ -887,7 +891,14 @@ runs:
|
|||||||
if [[ "$METRICS_IS_RELEASED" -gt "0" ]]; then
|
if [[ "$METRICS_IS_RELEASED" -gt "0" ]]; then
|
||||||
echo "Using released version $METRICS_TAG, will pull docker image from GitHub registry"
|
echo "Using released version $METRICS_TAG, will pull docker image from GitHub registry"
|
||||||
METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_TAG
|
METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_TAG
|
||||||
docker image pull $METRICS_IMAGE > /dev/null
|
docker image pull $METRICS_IMAGE
|
||||||
|
# Use registry for unreleased version with pre-built images
|
||||||
|
elif [[ ! $METRICS_USE_PREBUILT_IMAGE =~ ^([Ff]alse|[Oo]ff|[Nn]o|0)$ ]]; then
|
||||||
|
METRICS_TAG="$METRICS_TAG-beta"
|
||||||
|
echo "Image tag (updated): $METRICS_TAG"
|
||||||
|
echo "Using pre-built version $METRICS_TAG, will pull docker image from GitHub registry"
|
||||||
|
METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_TAG
|
||||||
|
docker image pull $METRICS_IMAGE
|
||||||
# Rebuild image for unreleased version
|
# Rebuild image for unreleased version
|
||||||
else
|
else
|
||||||
echo "Using an unreleased version ($METRICS_VERSION)"
|
echo "Using an unreleased version ($METRICS_VERSION)"
|
||||||
@@ -902,18 +913,19 @@ runs:
|
|||||||
|
|
||||||
# Build image if necessary
|
# Build image if necessary
|
||||||
set +e
|
set +e
|
||||||
docker image inspect $METRICS_IMAGE > /dev/null
|
docker image inspect $METRICS_IMAGE
|
||||||
METRICS_IMAGE_NEEDS_BUILD="$?"
|
METRICS_IMAGE_NEEDS_BUILD="$?"
|
||||||
set -e
|
set -e
|
||||||
if [[ "$METRICS_IMAGE_NEEDS_BUILD" -gt "0" ]]; then
|
if [[ "$METRICS_IMAGE_NEEDS_BUILD" -gt "0" ]]; then
|
||||||
echo "Image $METRICS_IMAGE is not present locally, rebuilding it from Dockerfile"
|
echo "Image $METRICS_IMAGE is not present locally, rebuilding it from Dockerfile"
|
||||||
docker build -t $METRICS_IMAGE . > /dev/null
|
docker build -t $METRICS_IMAGE .
|
||||||
else
|
else
|
||||||
echo "Image $METRICS_IMAGE is present locally"
|
echo "Image $METRICS_IMAGE is present locally"
|
||||||
fi
|
fi
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
# Run docker image with current environment
|
# Run docker image with current environment
|
||||||
docker run --init --volume $GITHUB_EVENT_PATH:$GITHUB_EVENT_PATH --env-file .env $METRICS_IMAGE
|
docker run --init --volume $GITHUB_EVENT_PATH:$GITHUB_EVENT_PATH --volume $METRICS_RENDERS:/renders --env-file .env $METRICS_IMAGE
|
||||||
rm .env
|
rm .env
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in New Issue
Block a user