Skip to content

Commit

Permalink
Try to fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Margen67 authored Apr 25, 2022
1 parent 63781a2 commit 8387090
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/autoclose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# TODO: Use cache to avoid API limits(?)
# TODO: Check issues/log/screenshots(?)
case "$GITHUB_EVENT_NAME" in
case $GITHUB_EVENT_NAME in
issues)
github_event_name_friendly=Issue
issue_body_trim() {
Expand All @@ -44,8 +44,8 @@ jobs:
issue_comment)
issue_comment_author_whitelist=(benvanik BillieBlueberry CookiePLMonster DrChat emoose Etokapa gibbed Gliniak halotroop2288 illusion0001 Margen67 Nighterlev Prism019 randprint Razzile Triang3l ZolaKluke)
for whitelisted_author in "${issue_comment_author_whitelist[@]}"; do
if [ "$issue_comment_author" = "$whitelisted_author" ] && [ -z "$issue_comment_author_whitelisted" ]; then
issue_comment_author_whitelisted=true
if [[ "$issue_comment_author" = "$whitelisted_author" && -z "$issue_comment_author_whitelisted" ]]; then
issue_comment_author_whitelisted=1
break
fi
done
Expand All @@ -58,17 +58,17 @@ jobs:
echo "$1"
compatibility_report_invalid_reasons+=$'\n'" * $1"
}
if [ "$GITHUB_EVENT_NAME" != issue_comment ]; then
if [ "$GITHUB_EVENT_NAME" = pull_request ]; then
if [ $GITHUB_EVENT_NAME != issue_comment ]; then
if [ $GITHUB_EVENT_NAME = pull_request ]; then
issue_title="$pull_request_title"
fi
# Check issue/pull request title
## TODO: Fix validation of '######## - '
if [[ "$issue_title" =~ ^([0-9A-F]{8} - .+)$ ]]; then
if [ "$GITHUB_EVENT_NAME" = issues ]; then
if [ $GITHUB_EVENT_NAME = issues ]; then
echo 'Title is valid.'
## Check for duplicate(s)
if [ '${{ github.event.action }}' = opened ]; then
if [ ${{ github.event.action }} = opened ]; then
repository_issues_json=$(gh api graphql --jq '.data.repository[]' --paginate -f query='
query($endCursor: String) {
repository(owner: "xenia-project", name: "game-compatibility") {
Expand Down Expand Up @@ -103,12 +103,12 @@ jobs:
else
compatibility_report_invalidate "Compatibility reports can't be pull requests."
fi
elif [ "$GITHUB_EVENT_NAME" = issues ]; then
elif [ $GITHUB_EVENT_NAME = issues ]; then
compatibility_report_invalidate 'Title is invalid.'
elif [ "$GITHUB_EVENT_NAME" = pull_request ]; then
elif [ $GITHUB_EVENT_NAME = pull_request ]; then
echo 'Pull request is probably valid.'
fi
if [ "$GITHUB_EVENT_NAME" = issues ]; then
if [ $GITHUB_EVENT_NAME = issues ]; then
# Check Xenia version
issue_body_trim 'Xenia version'
if [[ "$issue_body_trim" =~ https://github.com/xenia-project/xenia/commit/[0-9a-f]{5,40} ]]; then
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
}
')
repository_labels_invalid=(issue-{invalid,duplicate,superseded,cluttered} state-crash-OBSOLETE)
case "$GITHUB_EVENT_NAME" in
case $GITHUB_EVENT_NAME in
issues)
issue_body_trim Labels
issue_labels_body=($(
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
fi
done
issue_labels_state_count=$(echo "$labels_to_add" | grep -o state- | wc -l)
if [ $issue_labels_state_count -eq 1 ] && [[ ! "$labels_to_add" =~ 'state-crash-OBSOLETE' ]]; then
if [[ $issue_labels_state_count -eq 1 && ! "$labels_to_add" =~ 'state-crash-OBSOLETE' ]]; then
echo 'State label was provided.'
elif [ $issue_labels_state_count -gt 1 ]; then
compatibility_report_invalidate 'Multiple state labels were provided.'
Expand All @@ -192,7 +192,7 @@ jobs:
compatibility_report_invalidate 'Marketplace link and/or label(s) are invalid or missing.'
fi;;
issue_comment)
if [ "$issue_comment_author_whitelisted" = true ]; then
if [ -n "$issue_comment_author_whitelisted" ]; then
for repository_label in "${repository_labels[@]}"; do
if [[ "$issue_comment_body" =~ "$repository_label" ]]; then
if [[ ! "${repository_labels_invalid[@]}" =~ "$repository_label" ]]; then
Expand All @@ -209,7 +209,7 @@ jobs:
## Remove trailing comma
labels_to_add="${labels_to_add/%,/}"
issue_labels_state_count=$(echo "$labels_to_add" | grep -o state- | wc -l)
if [ $issue_labels_state_count -eq 1 ] && [[ ! "$labels_to_add" =~ 'state-crash-OBSOLETE' ]]; then
if [[ $issue_labels_state_count -eq 1 && ! "$labels_to_add" =~ 'state-crash-OBSOLETE' ]]; then
echo 'State label was provided.'
elif [ $issue_labels_state_count -gt 1 ]; then
unset labels_to_add ## TODO: Is there a better way of doing this?
Expand All @@ -232,24 +232,24 @@ jobs:
if [ -z "$compatibility_report_invalid_reasons" ]; then
echo "$github_event_name_friendly is valid."
if [ $issue_state = closed ] && [[ "$issue_labels" =~ ${repository_labels_invalid[0]}|${repository_labels_invalid[1]} ]]; then
if [[ $issue_state = closed && "$issue_labels" =~ ${repository_labels_invalid[0]}|${repository_labels_invalid[1]} ]]; then
## TODO: Hide (or delete) the close comment if issue is reopened
gh issue edit $issue_number --remove-label "${repository_labels_invalid[0]},${repository_labels_invalid[1]}"
gh issue reopen $issue_number
fi
else
echo "$github_event_name_friendly is invalid."
## Closing "invalid" (i.e. potentially outdated) edited issues is too risky
if [ '${{ github.event.action }}' = opened ]; then ## Only comment on 'opened' to prevent duplicate comments
if [ "$GITHUB_EVENT_NAME" = pull_request ]; then
if [[ ${{ github.event.action }} = opened && $GITHUB_EVENT_NAME != issue_comment ]]; then ## Only comment on 'opened' to prevent duplicate comments
if [ $GITHUB_EVENT_NAME = pull_request ]; then
issue_number="$pull_request_number"
issue_author="$pull_request_author"
fi
gh "${github_event_name_friendly,,}" close $issue_number
gh ${github_event_name_friendly,,} close $issue_number
comment_close_body="@$issue_author your ${github_event_name_friendly,,} was automatically closed because it didn't follow the [issue/report guidelines](https://github.com/xenia-project/game-compatibility#reportissue-guidelines)."
comment_close_body+=$'\n'"Here is what's wrong with your compatibility report:"
comment_close_body+="$compatibility_report_invalid_reasons"
if [ "$GITHUB_EVENT_NAME" = issues ]; then
if [ $GITHUB_EVENT_NAME = issues ]; then
comment_close_body+=$'\n\n'"**Don't submit a new ${github_event_name_friendly,,}.** Just edit this one and if it's valid it will be automatically reopened."
fi
comment_close_body+=$'\n\n'"If you want help with Xenia and/or your game go to our Discord server's #help channel: https://discord.gg/Q9mxZf9"
Expand Down

0 comments on commit 8387090

Please sign in to comment.