diff --git a/action.yml b/action.yml index de48848..5ccbddf 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,10 @@ inputs: default: 'work-in-progress,wip' REMOVE_LABEL: description: 'Remove the previous dependent label' + SKIP_DRAFTS: + description: 'Wheter to skip draft PRs or not. Defaults to include them' + default: true + runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index d76b6a6..6887629 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,6 +26,11 @@ if [[ -z "$AFTER_DAYS" ]]; then AFTER_DAYS=3 fi +if [[ -z "$SKIP_DRAFTS" ]]; then + echo "Setting the default SKIP_DRAFTS variable value." + SKIP_DRAFTS=false +fi + URI="https://api.github.com" API_HEADER="Accept: application/vnd.github.v3+json" AUTH_HEADER="Authorization: token $GITHUB_TOKEN" @@ -38,7 +43,7 @@ OPEN_PULL_REQUESTS=$( "$URI/repos/$GITHUB_REPOSITORY/issues?state=open" ) -PULL_REQUESTS=$(echo "$OPEN_PULL_REQUESTS" | jq --raw-output '.[] | {number: .number, created_at: .created_at, labels: .labels} | @base64') +PULL_REQUESTS=$(echo "$OPEN_PULL_REQUESTS" | jq --raw-output '.[] | {number: .number, created_at: .created_at, labels: .labels, draft: .draft} | @base64') for PULL_REQUEST in $PULL_REQUESTS; do PULL_REQUEST_INFO="$(echo "$PULL_REQUEST" | base64 -d)" @@ -84,6 +89,13 @@ for PULL_REQUEST in $PULL_REQUESTS; do "$URI/repos/$GITHUB_REPOSITORY/issues/$PULL_REQUEST_NUMBER/labels/$REMOVE_LABEL" else echo "Proceeding, This pull request doesn't have the label to remove: $REMOVE_LABEL" + + if [[ $SKIP_DRAFTS != "false" ]]; then + IS_A_DRAFT=$(echo "$PULL_REQUEST_INFO" | jq --raw-output '.draft') + if [[ $IS_A_DRAFT == "true" ]]; then + echo "Ignoring, this pull request because it's a DRAFT" + continue + fi fi