mirror of
https://github.com/Mesteriis/hassio-addons-avm.git
synced 2026-01-10 07:21:01 +01:00
v2
This commit is contained in:
69
.github/workflows/on_issues.yml
vendored
Normal file
69
.github/workflows/on_issues.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
# 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/Mesteriis/hassio-addons-avm/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
|
||||
|
||||
Reference in New Issue
Block a user