workflow improvements (#840)

* 20 min seems to be too short, it skips some PRs
* fixed to proper URL printing in logs
pull/846/head
Yuri Astrakhan 2020-04-30 11:50:45 -04:00 zatwierdzone przez GitHub
rodzic 99f9336e5e
commit 5445a70c30
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -20,7 +20,7 @@ jobs:
MSG_ARTIFACT_NAME: "pr_message"
# How far back to look for finished runs, in minutes.
# Set to 10-20 minutes higher than cron's job frequency set above.
IGNORE_RUNS_OLDER_THAN: 20
IGNORE_RUNS_OLDER_THAN: 80
# How far back to look for updated pull requests, in minutes.
# Should be bigger than IGNORE_RUNS_OLDER_THAN by the maximum time a pull request jobs may take
IGNORE_PRS_OLDER_THAN: 80
@ -47,6 +47,10 @@ jobs:
"$1"
}
auth_crl() {
crl "$1" -H "authorization: Bearer $GITHUB_TOKEN" "${@:2}"
}
#
# Parse current pull requests
#
@ -182,7 +186,7 @@ jobs:
fi
echo "Downloading artifact $ARTIFACT_URL (assuming single text file per artifact)..."
if ! MESSAGE="$(crl "$ARTIFACT_URL" -H "authorization: Bearer $GITHUB_TOKEN" | gunzip)"; then
if ! MESSAGE="$(auth_crl "$ARTIFACT_URL" | gunzip)"; then
echo "Unable to download or parse message from artifact '$MSG_ARTIFACT_NAME' in workflow $RUN_ID (PR #$PR_NUMBER), skipping..."
continue
fi
@ -209,13 +213,12 @@ jobs:
' <( echo "$EXISTING_PR_COMMENTS" ) )"
if [ -z "$OLD_COMMENT" ]; then
COMMENT_URL="$(crl "$GITHUB_API/issues/$PR_NUMBER/comments" \
COMMENT_HTML_URL="$(auth_crl "$GITHUB_API/issues/$PR_NUMBER/comments" \
-X POST \
-H "Content-Type: application/json" \
-H "authorization: Bearer $GITHUB_TOKEN" \
--data "$MESSAGE_BODY" \
| jq -r '.html_url' )"
COMMENT_INFO="New comment $COMMENT_URL was created"
COMMENT_INFO="New comment $COMMENT_HTML_URL was created"
else
# Make sure the content of the message has changed
COMMENT_URL="$(jq -r '
@ -229,14 +232,13 @@ jobs:
continue
fi
crl "$COMMENT_URL" \
COMMENT_HTML_URL="$(auth_crl "$COMMENT_URL" \
-X PATCH \
-H "authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data "$MESSAGE_BODY" \
| jq -r '("Updated existing comment " + .html_url)'
| jq -r '.html_url' )"
COMMENT_INFO="Existing comment $COMMENT_URL was updated"
COMMENT_INFO="Existing comment $COMMENT_HTML_URL was updated"
fi
echo "$COMMENT_INFO from workflow $WORKFLOW_NAME #$RUN_ID"