This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build VitePress, Pull Types, and Push to Private Repo | |
on: | |
push: | |
branches: [main] | |
jobs: | |
setup-and-build: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Pull types from type repo | |
env: | |
TYPE_REPO_TOKEN: ${{ secrets.TYPE_REPO_TOKEN }} | |
run: | | |
git clone --depth 1 https://${TYPE_REPO_TOKEN}@github.com/M1hono/CrychicDocTypes.git type_repo | |
cp -r type_repo/typefiles . | |
rm -rf type_repo | |
echo "Types pulled successfully" | |
- name: Configure Yarn to use a faster registry | |
run: yarn config set registry https://registry.npmmirror.com | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20.17.0" | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build VitePress site | |
env: | |
NODE_OPTIONS: --max-old-space-size=8192 | |
run: | | |
echo "Building VitePress site..." | |
yarn docs:build | |
- name: Push to private repo | |
env: | |
PRIVATE_REPO_TOKEN: ${{ secrets.PRIVATE_REPO_TOKEN }} | |
run: | | |
cd .vitepress/dist | |
git init | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
git clone --depth 1 https://${PRIVATE_REPO_TOKEN}@github.com/M1hono/CrychicDocSynchronization.git temp_repo | |
if [ -d temp_repo/.github ]; then | |
cp -r temp_repo/.github . | |
fi | |
rm -rf temp_repo | |
git add -A | |
git commit -m "Update documentation" | |
git push --force https://${PRIVATE_REPO_TOKEN}@github.com/M1hono/CrychicDocSynchronization.git HEAD:main | |
- name: Cleanup | |
run: | | |
rm -rf typefiles | |
rm -rf .vitepress/dist |