From 3de4d0984d478f4126adc236994a605aba8bb94a Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Fri, 3 Jun 2022 04:27:20 +0200 Subject: [PATCH] support action input for release draft body --- action.yaml | 7 ++++++- run.sh | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index f514eef..78b30fd 100644 --- a/action.yaml +++ b/action.yaml @@ -11,13 +11,18 @@ inputs: By default excludes 📦📝👻🚦 under the assumption these do not normally merit a release. An output of interesting = true/false will be set, the 'workflow_dispatch' (explicit release) is always 'interesting'. default: '[💥🚨🎉🐛⚠🚀🌐👷]|:(boom|tada|construction_worker):' + RELEASE_DRAFT_BODY: + required: false + description: | + Release draft body produced by release drafter github action + default: "" outputs: interesting: description: whether the category is interesting or not, true / false will be the result value: ${{ steps.interesting-category.outputs.interesting }} runs: using: composite - steps: + steps: - run: GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }} INTERESTING_CATEGORIES='${{ inputs.INTERESTING_CATEGORIES }}' $GITHUB_ACTION_PATH/run.sh id: interesting-category shell: bash diff --git a/run.sh b/run.sh index 49aa64a..5bf1d3e 100755 --- a/run.sh +++ b/run.sh @@ -2,7 +2,11 @@ set -euxo pipefail if [ $GITHUB_EVENT_NAME = check_run ] then - RESULT=$(gh api /repos/$GITHUB_REPOSITORY/releases | jq -e -r '.[] | select(.draft == true and .name == "next") | .body' | egrep "$INTERESTING_CATEGORIES" || echo 'failed') + if [ -z "$RELEASE_DRAFT_BODY" ]; then + RESULT=$(gh api /repos/$GITHUB_REPOSITORY/releases | jq -e -r '.[] | select(.draft == true and .name == "next") | .body' | egrep "$INTERESTING_CATEGORIES" || echo 'failed') + else + RESULT=$(echo "$RELEASE_DRAFT_BODY" | egrep "$INTERESTING_CATEGORIES" || echo 'failed') + fi if [[ $RESULT != 'failed' ]]; then echo "::set-output name=interesting::true" else