All checks were successful
Deploy Documentation / build-and-deploy (push) Successful in 55s
97 lines
3.7 KiB
YAML
97 lines
3.7 KiB
YAML
name: Deploy Documentation
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: docker # 기본 매핑된 node:20-bookworm 이미지에서 작동
|
|
steps:
|
|
- name: 저장소 체크아웃
|
|
uses: actions/checkout@v4
|
|
|
|
# 1. 기존 APT 캐시 복원 (가장 최근 상태 불러오기)
|
|
- name: Restore APT Cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: /var/cache/apt/archives
|
|
# 매칭되지 않는 임시 키를 사용하여 항상 restore-keys가 작동하도록 유도
|
|
key: ${{ runner.os }}-apt-temp
|
|
restore-keys: |
|
|
${{ runner.os }}-apt-
|
|
|
|
# 2. 시스템 패키지 설치 및 구버전 찌꺼기 청소
|
|
- name: Install System Packages
|
|
run: |
|
|
# 2-1. 다운로드된 패키지 파일이 지워지지 않도록 docker-clean 무력화
|
|
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
|
|
|
|
# 2-2. 패키지 업데이트 및 설치
|
|
apt-get update
|
|
apt-get install -y python3 python3-pip python3-venv graphviz
|
|
|
|
# 2-3. (핵심) 캐시 용량 최적화를 위해 더 이상 안 쓰는 구버전 패키지 파일만 삭제
|
|
apt-get autoclean -y
|
|
|
|
# 2-4. 다운로드 중단된 임시 파일 삭제 (캐시 오염 방지)
|
|
rm -f /var/cache/apt/archives/partial/*
|
|
|
|
# 3. .deb 파일명 목록 기반 고유 해시(Hash) 계산 (내용을 읽지 않아 초고속)
|
|
- name: Calculate APT Cache Hash
|
|
id: apt-hash
|
|
run: |
|
|
# 파일 내용 대신 이름(-printf "%f\n")만 추출하여 해시를 계산합니다.
|
|
# 새 파일이 생기거나 autoclean으로 파일이 지워졌을 때만 해시값이 바뀝니다.
|
|
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
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: /var/cache/apt/archives
|
|
# 내용물에 변화가 없으면 해시가 동일하므로 업로드를 자동으로 건너뜁니다 (Skip)
|
|
key: ${{ runner.os }}-apt-${{ steps.apt-hash.outputs.hash }}
|
|
|
|
- name: Cache Python Virtual Environment
|
|
id: cache-venv
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: venv
|
|
key: ${{ runner.os }}-venv-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-venv-
|
|
|
|
- name: Install Python Requirements
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
run: |
|
|
python3 -m venv venv
|
|
. venv/bin/activate
|
|
pip install -r requirements.txt
|
|
|
|
- name: Compile Docs
|
|
run: |
|
|
. venv/bin/activate
|
|
python3 build_docs.py
|
|
|
|
- name: gh-pages 브랜치로 site/ 배포
|
|
env:
|
|
# Forgejo Actions 가 자동 주입 — 추가 secret 등록 불필요
|
|
DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPO: ${{ github.repository }}
|
|
ACTOR: ${{ github.actor }}
|
|
run: |
|
|
cd site
|
|
git init -b master
|
|
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})"
|
|
git push --force \
|
|
"https://${ACTOR}:${DEPLOY_TOKEN}@1gnis-git.duckdns.org/${REPO}.git" \
|
|
master:gh-pages
|