-
Notifications
You must be signed in to change notification settings - Fork 2
152 lines (126 loc) · 4.76 KB
/
build.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
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
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: write
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:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Add index.md files for each directory
run: |
#!/bin/bash
for dir in */; do
if [[ -f "${dir}index.md" ]]; then
rm -f "${dir}index.md"
fi
printf "## Obsahuje témata: \n\n" > "${dir}index.md"
for file in "${dir}"*; do
FILENAME=$(printf "%s" "${file##*/}")
EXTENSION=$(printf "%s" "${FILENAME##*.}")
FILENAME=$(printf "%s" "${FILENAME%.*}")
if [[ -f "${file}" && "${FILENAME}" != "README" && "${FILENAME}" != "index" && "$EXTENSION" == "md" ]]; then
printf "### [%s](%s) \n" "${FILENAME}" "${FILENAME}" >> "${dir}index.md"
fi
done
done
- name: Add front matter to markdown files (for Jekyll to notice)
run: |
find . -type f -name "*.md" ! -name "README.md" -print0 | xargs -0 -I {} sh -c '
if ! grep -q "^---$" "{}"; then
parentpath=$(dirname "{}")
parentparentpath=$(dirname "$parentpath")
folderName=$(basename "$(dirname "{}")")
file="{}"
FILENAME=$(printf "%s" "${file##*/}")
siteTitle=$(awk "NR==1{print substr(\$0, 3)}" "{}" | tr -d ":")
sed -i "1s/^/---\\n/" "{}"
if [ "$FILENAME" = "index.md" ]; then
sed -i "2s/^/toc: false\\n/" "{}"
else
sed -i "2s/^/toc: true\\n/" "{}"
fi
sed -i "3s/^/layout: dark\\n/" "{}"
if [ "$FILENAME" = "index.md" ]; then
sed -i "4s/^/title: $folderName \\n/" "{}"
else
sed -i "4s|^|title: $FILENAME \\n|" "{}"
fi
if [ "$FILENAME" = "index.md" ]; then
sed -i "5s|^|parent_url: $parentparentpath \\n|" "{}"
else
sed -i "5s|^|parent_url: $parentpath \\n|" "{}"
fi
sed -i "6s/^/category: $folderName \\n/" "{}"
sed -i "7s/^/---\\n/" "{}"
fi
'
- name: format markdown files headers so Jekyll can read them correctly
run: |
find . -type f -name "*.md" ! -name "README.md" -print0 | xargs -0 -I {} sh -c '
if grep -q "^#" "{}"; then
sed -i -e "/^$/!s/^#/\n&/" "{}"
awk "/./ { e=0 } /^$/ { e += 1 } e <= 1" < "{}" > "temp" && mv temp "{}"
awk "/./ { e=0 } /^$/ { e += 1 } e <= 1" < "{}" > "temp" && mv temp "{}"
awk "/./ { e=0 } /^$/ { e += 1 } e <= 1" < "{}" > "temp" && mv temp "{}"
fi
'
- name: Commit changes
run: |
git config --global user.email "[email protected]"
git config --global user.name "tpkowastaken"
git add .
git commit -m "Build Jekyll site" --allow-empty
git push https://${{ secrets.TOKEN }}@github.com/tpkowastaken/Zapisky-CJ-SS.git HEAD:main
# Build job
- name: Checkout jekyll theme repo
uses: actions/checkout@v3
with:
repository: tpkowastaken/jekyll-dark-github-theme
path: repo-with-jekyll-theme
- name: Copy new files from first repo to second repo
run: |
cp -n -R repo-with-jekyll-theme/* ./
rm -rf repo-with-jekyll-theme/
shell: bash
- name: Set Permissions
run: |
sudo chown -R $USER .
sudo chmod -R 777 .
- name: Build with Jekyll
uses: docker://jekyll/builder:latest
with:
entrypoint: jekyll
args: build --config _config.yml --source ./ --destination ./_site --incremental
- name: Upload artifact to view
uses: actions/upload-artifact@v3
with:
name: site
path: _site
- name: Upload artifact for github pages
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v1
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2