All checks were successful
Deploy Documentation / build-and-deploy (push) Successful in 3m17s
93 lines
3.1 KiB
YAML
93 lines
3.1 KiB
YAML
name: Deploy Documentation
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: docker # 기본 매핑된 node:20-bookworm 이미지에서 작동
|
|
steps:
|
|
- name: 저장소 체크아웃
|
|
uses: actions/checkout@v4
|
|
|
|
# 1. 기존 APT 캐시 복원 (가장 최근 상태 불러오기)
|
|
- name: Restore APT Cache
|
|
id: restore-apt
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: /var/cache/apt/archives
|
|
key: linux-apt-temp
|
|
restore-keys: |
|
|
linux-apt-
|
|
|
|
# 2. 시스템 패키지 설치 및 구버전 찌꺼기 청소
|
|
- name: Install System Packages
|
|
run: |
|
|
if [ -f /etc/apt/apt.conf.d/docker-clean ]; then
|
|
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' | tee /etc/apt/apt.conf.d/keep-cache
|
|
rm -f /etc/apt/apt.conf.d/docker-clean
|
|
fi
|
|
|
|
apt-get update
|
|
apt-get install -y python3 python3-pip python3-venv graphviz
|
|
apt-get autoclean -y
|
|
rm -f /var/cache/apt/archives/partial/*
|
|
|
|
# 3. .deb 파일명 목록 기반 고유 해시(Hash) 계산
|
|
- name: Calculate APT Cache Hash
|
|
id: apt-hash
|
|
run: |
|
|
DEB_HASH=$(find /var/cache/apt/archives -name "*.deb" -type f -printf "%f\n" | sort | md5sum | awk '{print $1}')
|
|
echo "hash=$DEB_HASH" >> $GITHUB_OUTPUT
|
|
|
|
# 4. 계산된 해시값을 Key로 캐시 저장
|
|
- name: Save APT Cache
|
|
if: steps.restore-apt.outputs.cache-matched-key != format('linux-apt-{0}', steps.apt-hash.outputs.hash)
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: /var/cache/apt/archives
|
|
key: linux-apt-${{ steps.apt-hash.outputs.hash }}
|
|
|
|
- name: Cache Python Virtual Environment
|
|
id: cache-venv
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: venv
|
|
key: linux-venv-${{ hashFiles('requirements.txt', 'requirements-docs.txt') }}
|
|
restore-keys: |
|
|
linux-venv-
|
|
|
|
- name: Install Python Requirements
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
run: |
|
|
python3 -m venv venv
|
|
. venv/bin/activate
|
|
# Install simulation dependencies (needed for mkdocstrings dynamic import) and doc tools
|
|
pip install -r requirements.txt
|
|
pip install -r requirements-docs.txt
|
|
|
|
- name: Compile Docs
|
|
run: |
|
|
. venv/bin/activate
|
|
python3 build_docs.py
|
|
|
|
- name: gh-pages 브랜치로 site/ 배포
|
|
env:
|
|
DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPO: ${{ github.repository }}
|
|
ACTOR: ${{ github.actor }}
|
|
run: |
|
|
cd site
|
|
git init -b main
|
|
git config user.name "Forgejo Actions Bot"
|
|
git config user.email "actions@1gnis-git.duckdns.org"
|
|
git add .
|
|
git commit -m "Auto-deploy Docs (${GITHUB_SHA::8})"
|
|
SERVER_URL="${{ github.server_url }}"
|
|
HOST_ADDR="${SERVER_URL#*//}"
|
|
PROTO="${SERVER_URL%%//*}"
|
|
git push --force \
|
|
"${PROTO}//${ACTOR}:${DEPLOY_TOKEN}@${HOST_ADDR}/${REPO}.git" \
|
|
main:gh-pages
|