-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (99 loc) · 4.07 KB
/
gh-pages.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
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
name: Deploy site to GitHub Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-22.04
environment: github-pages
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup dependencies
run: |
sudo apt update
sudo apt install -y pandoc
- name: Build docs
run: |
find . -type f -name "*.md" -mindepth 2 -print0 | sort -z | while read -d $'\0' doc
do
output_dir=$(dirname "${doc}")
output_dir_name=$(basename "${output_dir}")
output_html="${output_dir}/index.html"
cp ./style.css "${output_dir}"
pandoc --template "template.html" --toc -c "style.css" --katex="https://cdn.jsdelivr.net/npm/[email protected]/dist/" -o "${output_html}" "${doc}" --metadata "toc-title=Indice" --metadata "lang=it"
done
- name: Create index.html
run: |
echo "<html lang= "en">\
<head>\
<meta charset="UTF-8">\
<meta name="viewport" content="width=device-width, initial-scale=1.0">\
<meta name="author" content="Nadav Moscovici">\
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">\
<link rel="stylesheet" href="css/index.css">\
<script src="js/index.js" defer></script>\
<title>Guides</title>\
</head>\
<body>\
<div id="menu">
<div id="menu-items">" >> index.html
find . -type d -mindepth 1 -maxdepth 1 -print0 | sort | while read -d $'\0' doc_dir
do
if [[ -f "${doc_dir}/index.html" ]]; then
echo "<a href=\"${doc_dir}/index.html\" class="menu-item">$(basename "${doc_dir}")</a>" >> index.html
fi
done
echo "</div>\
<div id="menu-background-pattern"></div>\
<div id="menu-background-image"></div>\
</div>\
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>\
</body>\
</html>" >> index.html
- name: Delete symlinks if any
run: |
find . -type l -delete
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./
# Deploy job
deploy:
# Add a dependency to the build job
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: github-pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action