This repository was archived by the owner on Sep 10, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11
83 lines (73 loc) · 3.23 KB
/
create-doc-on-issue.yml
File metadata and controls
83 lines (73 loc) · 3.23 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: 📁 Generate Error Documentation from Issues
on:
workflow_run:
workflows: ["Auto Create Issues Every 10 Minutes"]
types:
- completed
permissions:
contents: write
issues: read
jobs:
generate-doc:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download latest issue content
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue list --limit 1 --state open --json number,title,body > latest-issue.json
jq -r '.[0].title' latest-issue.json > title.txt
jq -r '.[0].body' latest-issue.json > body.txt
- name: Detect topic from title and body
id: topic
run: |
CONTENT=$(cat title.txt body.txt | tr '[:upper:]' '[:lower:]')
if echo "$CONTENT" | grep -q "nextjs"; then
echo "topic=nextjs" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "tailwind"; then
echo "topic=tailwinds" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "mern"; then
echo "topic=mern" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "react"; then
echo "topic=react" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "express"; then
echo "topic=expressjs" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "openai"; then
echo "topic=openai" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "vue"; then
echo "topic=vuejs" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "jquery"; then
echo "topic=jquery" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "javascript"; then
echo "topic=javascript" >> $GITHUB_OUTPUT
elif echo "$CONTENT" | grep -q "css"; then
echo "topic=css" >> $GITHUB_OUTPUT
else
echo "topic=general" >> $GITHUB_OUTPUT
fi
- name: Sanitize folder name from issue title
id: folder
run: |
FOLDER=$(cat title.txt | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//')
echo "folder=$FOLDER" >> $GITHUB_OUTPUT
- name: Create README.md from issue
run: |
mkdir -p "errors/${{ steps.topic.outputs.topic }}/${{ steps.folder.outputs.folder }}"
echo "# 🐞 $(cat title.txt)" > "errors/${{ steps.topic.outputs.topic }}/${{ steps.folder.outputs.folder }}/README.md"
echo "" >> "errors/${{ steps.topic.outputs.topic }}/${{ steps.folder.outputs.folder }}/README.md"
cat body.txt >> "errors/${{ steps.topic.outputs.topic }}/${{ steps.folder.outputs.folder }}/README.md"
- name: Set up Git identity as real user
run: |
git config user.name "openrocketsofficial"
git config user.email "motiontel@outlook.com"
- name: Commit and push with PAT
env:
TOKEN: ${{ secrets.OPENROCKETS_PAT }}
run: |
git add .
git commit -m "updated" || echo "Nothing to commit"
git remote set-url origin https://openrocketsofficial:${TOKEN}@github.com/${{ github.repository }}
git push origin HEAD