workflow improvements (#840)
* 20 min seems to be too short, it skips some PRs * fixed to proper URL printing in logs
This commit is contained in:
parent
99f9336e5e
commit
5445a70c30
20
.github/workflows/pr-updater.yml
vendored
20
.github/workflows/pr-updater.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
MSG_ARTIFACT_NAME: "pr_message"
|
MSG_ARTIFACT_NAME: "pr_message"
|
||||||
# How far back to look for finished runs, in minutes.
|
# How far back to look for finished runs, in minutes.
|
||||||
# Set to 10-20 minutes higher than cron's job frequency set above.
|
# 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.
|
# 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
|
# Should be bigger than IGNORE_RUNS_OLDER_THAN by the maximum time a pull request jobs may take
|
||||||
IGNORE_PRS_OLDER_THAN: 80
|
IGNORE_PRS_OLDER_THAN: 80
|
||||||
@ -47,6 +47,10 @@ jobs:
|
|||||||
"$1"
|
"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auth_crl() {
|
||||||
|
crl "$1" -H "authorization: Bearer $GITHUB_TOKEN" "${@:2}"
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse current pull requests
|
# Parse current pull requests
|
||||||
#
|
#
|
||||||
@ -182,7 +186,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Downloading artifact $ARTIFACT_URL (assuming single text file per artifact)..."
|
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..."
|
echo "Unable to download or parse message from artifact '$MSG_ARTIFACT_NAME' in workflow $RUN_ID (PR #$PR_NUMBER), skipping..."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -209,13 +213,12 @@ jobs:
|
|||||||
' <( echo "$EXISTING_PR_COMMENTS" ) )"
|
' <( echo "$EXISTING_PR_COMMENTS" ) )"
|
||||||
|
|
||||||
if [ -z "$OLD_COMMENT" ]; then
|
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 \
|
-X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "authorization: Bearer $GITHUB_TOKEN" \
|
|
||||||
--data "$MESSAGE_BODY" \
|
--data "$MESSAGE_BODY" \
|
||||||
| jq -r '.html_url' )"
|
| jq -r '.html_url' )"
|
||||||
COMMENT_INFO="New comment $COMMENT_URL was created"
|
COMMENT_INFO="New comment $COMMENT_HTML_URL was created"
|
||||||
else
|
else
|
||||||
# Make sure the content of the message has changed
|
# Make sure the content of the message has changed
|
||||||
COMMENT_URL="$(jq -r '
|
COMMENT_URL="$(jq -r '
|
||||||
@ -229,14 +232,13 @@ jobs:
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
crl "$COMMENT_URL" \
|
COMMENT_HTML_URL="$(auth_crl "$COMMENT_URL" \
|
||||||
-X PATCH \
|
-X PATCH \
|
||||||
-H "authorization: Bearer $GITHUB_TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "$MESSAGE_BODY" \
|
--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
|
fi
|
||||||
|
|
||||||
echo "$COMMENT_INFO from workflow $WORKFLOW_NAME #$RUN_ID"
|
echo "$COMMENT_INFO from workflow $WORKFLOW_NAME #$RUN_ID"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user