From 52dffcf414a3a7a2745ea06e59320f93365e4381 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Fri, 29 Nov 2024 11:50:12 +0800 Subject: [PATCH] chore(ci): optimize get-plugins.yml (#5752) * chore: optimize get-plugins.yml * fix: typo * fix: typo * chore: test * fix: bug * chore: optimize * chore: update * chore: update --- .github/workflows/get-plugins.yml | 51 +++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/.github/workflows/get-plugins.yml b/.github/workflows/get-plugins.yml index ac9b196fd5..348544a180 100644 --- a/.github/workflows/get-plugins.yml +++ b/.github/workflows/get-plugins.yml @@ -38,13 +38,52 @@ jobs: owner: nocobase skip-token-revoke: true - id: get-plugins + name: Get plugins shell: bash run: | - echo "all-plugins=$(gh search repos "props.plugin-type:custom,rc,beta,alpha,unreleased" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT" - echo "custom-plugins=$(gh search repos "props.plugin-type:custom" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT" - echo "rc-plugins=$(gh search repos "props.plugin-type:rc" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT" - echo "beta-plugins=$(gh search repos "props.plugin-type:beta,rc" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT" - echo "alpha-plugins=$(gh search repos "props.plugin-type:alpha,beta,rc" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT" - echo "unreleased-plugins=$(gh search repos "props.plugin-type:unreleased" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT" + function retry() { + local i=0 + local plugins="[]" + until [ "$i" -ge 2 ] + do + plugins=$(gh search repos "props.plugin-type:$1" --owner=nocobase --json name | jq -r 'map(.name) | tostring') && [[ "$plugins" != "[]" ]] && break + i=$((i+1)) + sleep 10 + done + echo $plugins + } + allPlugins=$(retry custom,rc,beta,alpha,unreleased) + if [[ "$allPlugins" == "[]" ]]; then + echo "Get all plugins empty" + exit 1 + fi + customPlugins=$(retry custom) + if [[ "$customPlugins" == "[]" ]]; then + echo "Get custom plugins empty" + exit 1 + fi + rcPlugins=$(retry rc) + rcPlugins=$(retry custom) + if [[ "$rcPlugins" == "[]" ]]; then + echo "Get rc plugins empty" + exit 1 + fi + betaPlugins=$(retry beta,rc) + if [[ "$betaPlugins" == "[]" ]]; then + echo "Get beta plugins empty" + exit 1 + fi + alphaPlugins=$(retry alpha,beta,rc) + if [[ "$alphaPlugins" == "[]" ]]; then + echo "Get alpha plugins empty" + exit 1 + fi + unreleasedPlugins=$(retry unreleased) + echo "all-plugins=$allPlugins" >> "$GITHUB_OUTPUT" + echo "custom-plugins=$customPlugins" >> "$GITHUB_OUTPUT" + echo "rc-plugins=$rcPlugins" >> "$GITHUB_OUTPUT" + echo "beta-plugins=$betaPlugins" >> "$GITHUB_OUTPUT" + echo "alpha-plugins=$alphaPlugins" >> "$GITHUB_OUTPUT" + echo "unreleased-plugins=$unreleasedPlugins" >> "$GITHUB_OUTPUT" env: GH_TOKEN: ${{ steps.app-token.outputs.token }}