-
-
Notifications
You must be signed in to change notification settings - Fork 223
69 lines (62 loc) · 2.73 KB
/
on_issues.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# yamllint disable rule:line-length
---
name: Readme Issues linker
on:
issues:
types: [opened, edited, closed]
workflow_dispatch:
jobs:
ISSUES_linked:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Assign issues
run: |
# Init
echo "Starting"
# Get issues list
curl -s -L https://api.github.com/repos/alexbelgium/hassio-addons/issues > issueslist
# Go through all folders, add to filters if not existing
for f in $( find -- * -maxdepth 0 -type d | sort -r ); do
if [ -f "$f"/config.json ]; then
# Clean previously reported issues
sed -i "/Open Issue :/d" "$f"/README.md
sed -i "/Open Request :/d" "$f"/README.md
# If there is an issue with the addon name in title, put a message
COUNTER=0
while [[ $(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].title" issueslist) != null ]]; do
#Increment counter
(( COUNTER=COUNTER+1 )) || true
#Get variables
TITLE="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].title" issueslist)"
TITLE="${TITLE//[<>\$\'\"]/}"
#Check if relevant to addon
SLUG="$(jq -r --arg f "$f" ".slug" "$f"/config.json)"
NAME="$(jq -r --arg f "$f" ".name" "$f"/config.json)"
if [[ "${TITLE,,}" == *"${f,,}"* ]] || [[ "${TITLE,,}" == *"${SLUG,,}"* ]] || [[ "${TITLE,,}" == *"${NAME,,}"* ]]; then
echo "Project $TITLE, $SLUG, $NAME has an issue"
REQ="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].user.login" issueslist)"
URL="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].html_url" issueslist)"
LABEL="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].labels[].name" issueslist)"
DATEISSUE="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].created_at" issueslist)"
DATEISSUE="${DATEISSUE%T*}"
if [[ "$LABEL" == *"bug"* ]]; then
sed -i "1i ## ⚠ Open Issue : [$TITLE (opened ${DATEISSUE})]($URL) by [@${REQ}](https://github.com/$REQ)" "$f"/README.md
elif [[ "$LABEL" == *"enhancement"* ]]; then
sed -i "1i ## ⚠ Open Request : [$TITLE (opened ${DATEISSUE})]($URL) by [@${REQ}](https://github.com/$REQ)" "$f"/README.md
fi
fi
done
fi
done
# Remove issues list
rm issueslist
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
message: "Github bot : issues linked to readme"
default_author: github_actions
commit: -u
fetch: --force
push: --force