Auto-regenerate files
This commit is contained in:
48
action.yml
48
action.yml
@@ -69,6 +69,11 @@ inputs:
|
||||
description: Rendered metrics output path
|
||||
default: github-metrics.svg
|
||||
|
||||
# Output action
|
||||
output_action:
|
||||
description: Output action
|
||||
default: commit
|
||||
|
||||
# Optimize SVG image to reduce its filesize
|
||||
# Some templates may not support this option
|
||||
optimize:
|
||||
@@ -167,7 +172,8 @@ inputs:
|
||||
description: Debug flags
|
||||
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:
|
||||
description: Enable dry-run
|
||||
default: no
|
||||
@@ -182,11 +188,12 @@ inputs:
|
||||
description: Use mocked data instead of live APIs
|
||||
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
|
||||
use_prebuilt_image:
|
||||
description: Use pre-built image from GitHub registry
|
||||
default: ""
|
||||
default: yes
|
||||
|
||||
# ====================================================================================
|
||||
# 📰 Recent activity
|
||||
@@ -846,13 +853,19 @@ runs:
|
||||
steps:
|
||||
- run: |
|
||||
# Create environment file from inputs and GitHub variables
|
||||
echo "::group::Metrics docker image setup"
|
||||
cd $METRICS_ACTION_PATH
|
||||
touch .env
|
||||
for INPUT in $(echo $INPUTS | jq -r 'to_entries|map("INPUT_\(.key|ascii_upcase)=\(.value|@uri)")|.[]'); do
|
||||
echo $INPUT >> .env
|
||||
done
|
||||
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)
|
||||
METRICS_SOURCE=$(echo $METRICS_ACTION | sed -E 's/metrics.*?$//g')
|
||||
@@ -864,20 +877,11 @@ runs:
|
||||
|
||||
# Image tag (extracted from version or from env)
|
||||
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"
|
||||
|
||||
# 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
|
||||
elif [[ $METRICS_SOURCE == "lowlighter" ]]; then
|
||||
if [[ $METRICS_SOURCE == "lowlighter" ]]; then
|
||||
# Is released version
|
||||
set +e
|
||||
METRICS_IS_RELEASED=$(expr $(expr match $METRICS_VERSION .*-beta) == 0)
|
||||
@@ -887,7 +891,14 @@ runs:
|
||||
if [[ "$METRICS_IS_RELEASED" -gt "0" ]]; then
|
||||
echo "Using released 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
|
||||
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
|
||||
else
|
||||
echo "Using an unreleased version ($METRICS_VERSION)"
|
||||
@@ -902,18 +913,19 @@ runs:
|
||||
|
||||
# Build image if necessary
|
||||
set +e
|
||||
docker image inspect $METRICS_IMAGE > /dev/null
|
||||
docker image inspect $METRICS_IMAGE
|
||||
METRICS_IMAGE_NEEDS_BUILD="$?"
|
||||
set -e
|
||||
if [[ "$METRICS_IMAGE_NEEDS_BUILD" -gt "0" ]]; then
|
||||
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
|
||||
echo "Image $METRICS_IMAGE is present locally"
|
||||
fi
|
||||
echo "::endgroup::"
|
||||
|
||||
# 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
|
||||
shell: bash
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user