-
-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (213 loc) · 13.2 KB
/
upgrade-documentation.yml
File metadata and controls
215 lines (213 loc) · 13.2 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
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
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 -f
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
- 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/debian/changelog wiki/
cd wiki
sed -i 's/Changelog/:octocat: Changelog :octocat:/g' changelog
sed -i 's/# /## /g' changelog
- 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: Rebuild the debian-createstructure locally
run: |
cd wiki
echo "## :octocat: Rebuild the debian-createstructure locally :octocat:" >> Rebuild-the-debian-createstructure-locally.md
echo "Install the manager-create locally permits you to do some debug and try new configurations." >> Rebuild-the-debian-createstructure-locally.md
echo "" >> Rebuild-the-debian-createstructure-locally.md
echo "### Steps:" >> Rebuild-the-debian-createstructure-locally.md
echo "- [:octocat: Rebuild the debian-createstructure locally :octocat:](#octocat-rebuild-the-debian-createstructure-locally-octocat)" >> Rebuild-the-debian-createstructure-locally.md
echo " - [Steps:](#steps)" >> Rebuild-the-debian-createstructure-locally.md
echo " - [1. Install VirtualBox on the PC](#1-install-virtualbox-on-the-pc)" >> Rebuild-the-debian-createstructure-locally.md
echo " - [2. Install Ubuntu](#2-install-ubuntu)" >> Rebuild-the-debian-createstructure-locally.md
echo " - [3. Install dependencies](#3-install-dependencies)" >> Rebuild-the-debian-createstructure-locally.md
echo " - [4. Compile](#4-compile)" >> Rebuild-the-debian-createstructure-locally.md
echo "" >> Rebuild-the-debian-createstructure-locally.md
echo "### 1. Install VirtualBox on the PC" >> Rebuild-the-debian-createstructure-locally.md
echo "For installation we suggest VirtualBox, a tool that allows you to create one or more virtual machines :computer:." >> Rebuild-the-debian-createstructure-locally.md
echo "If any of these crashes, in any case, your PC will not lose data, at most you will have to restart it :smile:." >> Rebuild-the-debian-createstructure-locally.md
echo "" >> Rebuild-the-debian-createstructure-locally.md
echo "To install VirtualBox on your PC you need to:" >> Rebuild-the-debian-createstructure-locally.md
echo "- Get in into the UEFI" >> Rebuild-the-debian-createstructure-locally.md
echo "- Enable the function which name is like \"Virtualization\" (for each UEFI this step is different but similar)" >> Rebuild-the-debian-createstructure-locally.md
echo "- Save the configuration and restart the PC" >> Rebuild-the-debian-createstructure-locally.md
echo "- Go to the [VirtualBox website](https://www.virtualbox.org/)" >> Rebuild-the-debian-createstructure-locally.md
echo "- Press \"Download\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Run the downloaded file" >> Rebuild-the-debian-createstructure-locally.md
echo "- Follow the installation steps" >> Rebuild-the-debian-createstructure-locally.md
echo "" >> Rebuild-the-debian-createstructure-locally.md
echo "### 2. Install Ubuntu" >> Rebuild-the-debian-createstructure-locally.md
echo "As the OS we suggest to use Ubuntu, because it is lightweight (for RAM and CPU) and it's free." >> Rebuild-the-debian-createstructure-locally.md
echo "" >> Rebuild-the-debian-createstructure-locally.md
echo "To install Ubuntu on VirtualBox you need to:" >> Rebuild-the-debian-createstructure-locally.md
echo "- Download the last LTS version of Ubuntu by the following link: [https://ubuntu.com/download/desktop](https://ubuntu.com/download/desktop)" >> Rebuild-the-debian-createstructure-locally.md
echo "> Now you can continue with the other steps during the download" >> Rebuild-the-debian-createstructure-locally.md
echo "- Open VirtualBox" >> Rebuild-the-debian-createstructure-locally.md
echo "- Press \"New\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Compile the form" >> Rebuild-the-debian-createstructure-locally.md
echo " - As name put \"rest-createstructure\"" >> Rebuild-the-debian-createstructure-locally.md
echo " - As Type: \"Linux\"" >> Rebuild-the-debian-createstructure-locally.md
echo " - As version: \"Ubuntu (64-bit)\" or \"Ubuntu (32-bit)\"" >> Rebuild-the-debian-createstructure-locally.md
echo " - Press \"Next >\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Set the RAM to use for the VirtualMachine, at most half of local RAM and press \"Next >\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Leave \"Create a virtual hard disk now\" and press \"Create\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Leave \"VDI ...\" and press \"Next >\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Leave \"Dynamically allocated\" and press \"Next >\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Change the hard disk memory, we suggest 16GB and press \"Create\"" >> Rebuild-the-debian-createstructure-locally.md
echo "> Make sure that Ubuntu download is finished before to continue" >> Rebuild-the-debian-createstructure-locally.md
echo "- On the VirtualBox console, selecting the created VM, press \"Start\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Select as start-up disk Ubuntu, already downloaded" >> Rebuild-the-debian-createstructure-locally.md
echo " - Press the folder icon" >> Rebuild-the-debian-createstructure-locally.md
echo " - Press \"Add\", in the top menu" >> Rebuild-the-debian-createstructure-locally.md
echo " - Select the Ubuntu iso, the file will have a structure like \"ubuntu-version-other_info.iso\"" >> Rebuild-the-debian-createstructure-locally.md
echo " - Press \"Choose\" and \"Start\"" >> Rebuild-the-debian-createstructure-locally.md
echo "- Follow the install steps (the installation needs some minutes)" >> Rebuild-the-debian-createstructure-locally.md
echo "" >> Rebuild-the-debian-createstructure-locally.md
echo "### 3. Install dependencies" >> Rebuild-the-debian-createstructure-locally.md
echo "Now you have to install building dependencies." >> Rebuild-the-debian-createstructure-locally.md
echo "To install Dependes on the Virtual Machine you need to:" >> Rebuild-the-debian-createstructure-locally.md
echo "- On the VM (Virtual Machine) open the terminal (\`Ctrl + Alt + T\`)" >> Rebuild-the-debian-createstructure-locally.md
echo "- On the terminal paste \`sudo apt update; sudo add-apt-repository ppa:jyrki-pulliainen/dh-virtualenv -y; sudo apt-get install git build-essential debhelper devscripts equivs dh-virtualenv python3.8 gnupg gnupg2 libcurl4-openssl-dev libssl-dev -y; git clone https://github.com/createstructure/debian-createstructure; cd debian-createstructure; echo \"3.0 (native)\" > ./debian/source/format\` and insert password" >> Rebuild-the-debian-createstructure-locally.md
echo "" >> Rebuild-the-debian-createstructure-locally.md
echo "### 4. Compile" >> Rebuild-the-debian-createstructure-locally.md
echo "To compile type: \`dpkg-buildpackage -us -uc\`" >> Rebuild-the-debian-createstructure-locally.md
echo "Now the .deb file is in the .. folder, you can install it with apt." >> Rebuild-the-debian-createstructure-locally.md
echo "" >> Rebuild-the-debian-createstructure-locally.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 >> repo/docs/README.md
cat wiki/Rebuild-the-debian-createstructure-locally.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