-
-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (156 loc) · 6.32 KB
/
upgrade-documentation.yml
File metadata and controls
158 lines (156 loc) · 6.32 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Upgrade documentation (Wiki + README.md)
on:
workflow_dispatch:
push:
branches-ignore:
- 'releases/*'
jobs:
UML-export:
runs-on: ubuntu-latest
environment:
name: UML
steps:
- uses: actions/checkout@v2
- name: Export UML
continue-on-error: true
uses: docker://rlespinasse/drawio-export:latest
with:
args: -f svg -o ./ docs
- name: git add & commit & upload repo
continue-on-error: true
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "help@castellanidavide.it"
git add *
git commit -m "Exported UML automatically"
git push https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git
upgrade-documentation:
needs: [UML-export]
runs-on: ubuntu-latest
environment:
name: documentation
steps:
- name: Initial setup
run: |
sudo apt update -y
sudo pip install BeautifulSoup4
{
git clone --recurse-submodules --depth 1 https://$.GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.wiki.git wiki
} || {
mkdir wiki
}
git clone --recurse-submodules --depth 1 https://$.GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git -b $(echo ${GITHUB_REF#refs/heads/}) repo
rm -f wiki/*.md
rm -f wiki/*.svg
- name: Home file
run: |
cd wiki
python3 << EOF
import requests
import json
from bs4 import BeautifulSoup
def web_request(url):
""" Make a web request and return the response
"""
return requests.get(url, auth=("$GITHUB_ACTOR", "${{ secrets.GITHUB_TOKEN }}")).text
def get_json():
""" Returns the json with description
"""
return json.loads(web_request("$GITHUB_API_URL/repos/$GITHUB_REPOSITORY"))
def get_social_img():
""" Get social image
"""
try:
soup = BeautifulSoup(web_request("$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"), 'html.parser')
return soup.find("meta", property="og:image")["content"]
except:
print("Error getting social image")
return ""
def get_content():
""" Returns the file content
"""
social_img = get_social_img()
file_content = "## :octocat: Description :octocat:\n"
file_content += get_json()["description"].replace(". ", ".\n\n").replace("wiki", "[wiki]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/wiki)") + "\n"
file_content += f"\n"
return file_content
if __name__ == "__main__":
open("Home.md", "w+").write(str(get_content()))
EOF
- name: Class UML file
run: |
cd wiki
echo "## :octocat: Class UML :octocat:" > Class-UML.md
echo "/docs/${{ github.event.repository.name }}-Class-UML.svg)" >> Class-UML.md
- name: CHANGELOG file
run: |
cp repo/docs/CHANGELOG.md wiki/CHANGELOG.md
cd wiki
sed -i 's/Changelog/:octocat: Changelog :octocat:/g' CHANGELOG.md
sed -i 's/# /## /g' CHANGELOG.md
- name: file
run: |
cp repo/docs/CHANGELOG.md wiki/CHANGELOG.md
cd wiki
sed -i 's/Changelog/:octocat: Changelog :octocat:/g' CHANGELOG.md
sed -i 's/# /## /g' CHANGELOG.md
- name: Directory structure file
run: |
cd wiki
sudo apt install tree -y
echo "## :octocat: Directory structure :octocat:" > Directory-Structure.md
echo "" >> Directory-Structure.md
echo "\`\`\`" >> Directory-Structure.md
tree ../repo >> Directory-Structure.md
echo "\`\`\`" >> Directory-Structure.md
sed -i 's/├── debian/├── debian # debian control code/g' Directory-Structure.md
sed -i 's/bin/bin # source code/g' Directory-Structure.md
sed -i 's/docs/docs # documentation/g' Directory-Structure.md
- name: _Footer file
run: |
cd wiki
echo "---" > _Footer.md
echo "Made w/ :heart: by Castellani Davide" >> _Footer.md
echo "" >> _Footer.md
echo "If you want to contribute you can start with:" >> _Footer.md
echo "- [Discussion]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/discussions)" >> _Footer.md
echo "- [Issue]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/issues/new)" >> _Footer.md
- name: _Header file
run: |
cd wiki
echo "# debian-createstructure" > _Header.md
echo "[]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/blob/$(echo ${GITHUB_REF#refs/heads/})/docs/LICENSE)" >> _Header.md
echo "" >> _Header.md
echo " " >> _Header.md
echo "" >> _Header.md
- name: Recreate README.md
run: |
cat wiki/_Header.md > repo/docs/README.md
cat wiki/Home.md >> repo/docs/README.md
cat wiki/Class-UML.md >> repo/docs/README.md
cat wiki/Directory-Structure.md >> repo/docs/README.md
cat wiki/CHANGELOG.md >> repo/docs/README.md
cat wiki/_Footer.md >> repo/docs/README.md
sed -i 's/:octocat://g' repo/docs/README.md
- name: git add & commit & upload wiki
continue-on-error: true
run: |
{
ls wiki/.git/ > /dev/null
} && {
cd wiki
git config user.name "$GITHUB_ACTOR"
git config user.email "help@castellanidavide.it"
git add *
git commit -m "Upgrade by automatic action"
git push https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.wiki.git
}
- name: git add & commit & upload repo
continue-on-error: true
run: |
cd repo
git config user.name "$GITHUB_ACTOR"
git config user.email "help@castellanidavide.it"
git add *
git commit -m "Upgrade by automatic action"
git push https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git