website/.forgejo/workflows/deploy.yml

45 lines
1.3 KiB
YAML
Raw Normal View History

2024-04-02 05:55:45 +00:00
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: debian-12
permissions:
contents: write
steps:
- uses: https://code.forgejo.org/actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
2024-04-02 05:55:45 +00:00
run: |
apt-get update -qq
apt-get install -qq dia python3
2024-09-12 01:18:01 +00:00
scripts/install_deps.sh
echo "`pwd`"/bin >> $GITHUB_PATH
2024-04-02 05:55:45 +00:00
- name: Build Book
run: |
2024-09-12 01:18:01 +00:00
mdbook-mermaid install .
2024-04-02 05:55:45 +00:00
mdbook build
- name: Push to rendered branch
run: |
hash="$(git log -n 1 --format=reference)"
2024-04-02 06:22:21 +00:00
git branch -D rendered &> /dev/null || true
git worktree add --detach --no-checkout dist
2024-04-11 09:00:06 +00:00
cd dist
git switch --orphan=rendered
cd ..
2024-04-02 05:55:45 +00:00
mv dist/.git book/.git
2024-04-02 06:22:21 +00:00
rmdir dist
2024-04-02 05:55:45 +00:00
mv book/ dist/
cd dist
git add .
2024-04-02 06:22:21 +00:00
git config user.name "CI"
git config user.email "ci@noreply.libre-chip.org"
2024-04-02 05:55:45 +00:00
git commit -n -m "rendered version of $hash"
2024-04-02 06:36:29 +00:00
[[ "${{ github.server_url }}" =~ ^"https://"(.*)$ ]]
git remote set-url origin "https://x-access-token:${{ github.token }}@${BASH_REMATCH[1]}/${{ github.repository }}"
git push -f origin rendered