Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sgowroji authored Feb 27, 2023
2 parents d9f4c34 + e258aeb commit b83ca5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
14 changes: 13 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit b83ca5d

Please sign in to comment.