From a0a620a35f4989300ed969187f1e77d6859244a4 Mon Sep 17 00:00:00 2001 From: Artem Yegorov Date: Wed, 16 Oct 2024 22:11:36 +0300 Subject: [PATCH] #345: make popular options transmission directly to YAML configuration --- Makefile | 1 + README.md | 12 +++++++++--- action.yml | 6 ++++++ entry.sh | 11 ++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index afcd0571..12e3a82a 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ entry: target/docker-image.txt -e "INPUT_VERBOSE=true" \ -e "INPUT_PAGES=pages" \ -e "INPUT_TOKEN=00000000-0000-0000-0000-000000000000" \ + -e "INPUT_GITHUB_TOKEN=00000000-0000-0000-0000-000000000000" \ -e "INPUT_OPTIONS=$$(cat target/opts.txt)" \ "$${img}" echo "$$?" > target/entry.exit diff --git a/README.md b/README.md index 2a201a28..be88c5ad 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,8 @@ jobs: - uses: zerocracy/judges-action@0.0.55 with: token: ${{ secrets.ZEROCRACY_TOKEN }} - options: | - github_token=${{ secrets.GITHUB_TOKEN }} - repositories=... + github_token: ${{ secrets.GITHUB_TOKEN }} + repositories: yegor256/judges,yegor256/factbase,zerocracy/* factbase: foo.fb - uses: zerocracy/pages-action@0.0.40 with: @@ -78,6 +77,13 @@ The following options are expected by the plugin * `options` (mandatory) is a list of `k=v` pairs, which are explained below * `factbase` (mandatory) is the path of the [Factbase][factbase] file (where everything is kept) +* `repositories` (optional) is a comma-separated list of masks that + determine the repositories to manage, where + `yegor256/*` means all repos of the user, + `yegor256/judges` means a specific repo, + and + `-yegor256/judges` means an exclusion of the repo from the list. +* `github_token` (optional) is an authentication GitHub access token * `verbose` (optional) makes it print debugging info if set to `true` * `cycles` (optional) is a number of update cycles to run diff --git a/action.yml b/action.yml index 74c9efff..2fddada1 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,12 @@ inputs: options: description: 'Command line options for the "judges" tool' required: false + repositories: + description: 'Comma-separated list of masks that determine the repositories to manage' + required: false + github_token: + description: 'Authentication GitHub access token' + required: false verbose: description: 'Log as much debug information as possible' required: false diff --git a/entry.sh b/entry.sh index 30d219cc..1040c5bb 100755 --- a/entry.sh +++ b/entry.sh @@ -83,6 +83,10 @@ GITHUB_REPO_NAME="${GITHUB_REPOSITORY#"${GITHUB_REPOSITORY_OWNER}/"}" VITALS_URL="https://${GITHUB_REPOSITORY_OWNER}.github.io/${GITHUB_REPO_NAME}/${name}-vitals.html" # Add new facts, using the judges (Ruby scripts) in the /judges directory +declare -A optionmap=( + ["repositories"]="${INPUT_REPOSITORIES}" + ["github_token"]="${INPUT_GITHUB_TOKEN}" +) declare -a options=() while IFS= read -r o; do s=$(echo "${o}" | xargs) @@ -93,8 +97,13 @@ while IFS= read -r o; do VITALS_URL="${v}" continue fi - options+=("--option=${k}=${v}") + optionmap[$k]=$v done <<< "${INPUT_OPTIONS}" +for k in "${!optionmap[@]}"; do + if [ -n "${optionmap[$k]}" ]; then + options+=("--option=${k}=${optionmap[$k]}"); + fi +done options+=("--option=judges_action_version=${VERSION}") options+=("--option=vitals_url=${VITALS_URL}")