Skip to content

Update test-2.yml

Update test-2.yml #10

Workflow file for this run

name: Test-2 Workflow Name
on:
push:
branches:
- playground
paths:
- .github/workflows/test-2.yml
workflow_dispatch:
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- shell: bash
run: |
echo "Env:"
env | awk -F '=' '{ printf(" %-25s = ", $1); for (i = 2; i <= NF; i++) printf("%s", $i); print ""; }'
# Iterate through all environment variables
for var in $(compgen -e); do
# Get the value of the environment variable
value="${!var}"
realpath="$( realpath "$value" 2>/dev/null )"
[[ -z "${realpath}" || ! -f "${realpath}" ]] && continue
echo "Testing '$value'"
file --mime-encoding "$realpath"
# Check if the value is a readable file
if file -b "$value" | grep -q "text" ; then
# Print the header with the realpath of the file
printf '%s=File: `%s`' "$var" "$value"
[[ "$value" != "$realpath" ]] && echo " [$realpath]" || echo
# If the file is a JSON file, use jq to pretty-print it
if [[ "$(file -b --mime-type "$value")" == "application/json" ]]; then
echo " JSON content:"
jq -C -S . "$value" | sed 's/^/ /'
else
# Otherwise, print the content indented with two spaces
echo " Content:"
echo " $(cat "$value")"
fi
fi
done