backie/docs/deploy.sh
Pmarquez 8b6e5c19b8
Docs site (#82)
* init static site

* add index

* changes footer

* remove search

* add docs workflows

* remove unused pages

* remove commit step

* README and CHANGELOG added, also fix cron typo

* Sorry ayrat my bad xd

* little glitch

* fix base url

* dates modify

* fix authors

* change structure

* don't remove docs :]

* remove rust code for static site

* copy recursively

* add random attribute

* remove submodules

* more fixes

* master branch

* CHANGELOG AND README update automated

* fix ref

* Icons may be work ?

* fix deploy bug

* i think fix the deploy bug

* gitignore README and CHANGELOG

* delete -f

* delete desc

* delete lead

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>
2022-09-07 19:24:17 +03:00

61 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
BRANCH="gh-pages"
current_time() {
TIME=$(date -u --rfc-3339=seconds)
DATE=$(echo $TIME | cut -d' ' -f1)
HOUR=$(echo $TIME | cut -d' ' -f2)
VALID_TIME=${DATE}T${HOUR}
echo $VALID_TIME
}
build() {
echo "Starting building..."
TIME=$(current_time)
printf "+++\ntitle = \"CHANGELOG\"\ndate = $TIME\nupdated = $TIME\ndraft = false\nweight = 410\nsort_by = \"weight\"\ntemplate = \"docs/page.html\"\n\n[extra]\ntoc = true\ntop = false\n+++\n\n" > docs/content/docs/CHANGELOG.md
cat CHANGELOG.md >> docs/content/docs/CHANGELOG.md
printf "+++\ntitle = \"README\"\ndate = $TIME\nupdated = $TIME\ndraft = false\nweight = 410\nsort_by = \"weight\"\ntemplate = \"docs/page.html\"\n\n[extra]\ntoc = true\ntop = false\n+++\n\n" > docs/content/docs/README.md
cat README.md >> docs/content/docs/README.md
cp -R docs ../docs_backup
rm -r *
cp -R ../docs_backup ./docs
cd docs
sudo snap install --edge zola
zola build
mv public /tmp/public
cd ..
}
deploy() {
echo "Starting deploying..."
git config --global url."https://".insteadOf git://
git config --global url."https://github.com/".insteadOf git@github.com:
git checkout ${BRANCH}
cp -vr /tmp/public/* .
git config user.name "GitHub Actions"
git config user.email "github-actions-bot@users.noreply.github.com"
rm -r docs/themes
git add .
git commit -m "Deploy new version docs"
git push --force "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" ${BRANCH}
echo "Deploy complete"
}