Skip to content

Commit

Permalink
cache me outside, how about that
Browse files Browse the repository at this point in the history
Meme wanted this commit title, ask him lmao
  • Loading branch information
taskylizard committed Sep 20, 2024
1 parent 70f5244 commit c2db4ce
Show file tree
Hide file tree
Showing 5 changed files with 703 additions and 376 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Deploy Docs

on:
push:
branches: [main]
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [20]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 6

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

# - name: Cache Vitepress
# uses: actions/cache@v4
# with:
# path: docs/.vitepress/cache
# key:
# ${{ runner.os }}-vitepress-${{ hashFiles('docs/.vitepress/cache/**','pnpm-lock.yaml') }}
# restore-keys: ${{ runner.os }}-vitepress-

- name: Build docs
run: pnpm docs:build

- name: Deploy to server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
WORK_DIR: ${{ secrets.WORK_DIR }}
SSH_USER: ${{ secrets.SSH_USER }}
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
ssh-keyscan -H $SSH_HOST >> ~/.ssh/known_hosts
echo "Installed SSH key"
rsync -ravz --update --delete docs/.vitepress/dist/* $SSH_USER@$SSH_HOST:$WORK_DIR
rm -f ~/.ssh/id_rsa
- name: Purge Cloudflare Cache
env:
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
CF_ACCOUNT_MAIL: ${{ secrets.CF_ACCOUNT_MAIL }}
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
run: |
curl --request POST \
--url https://api.cloudflare.com/client/v4/zones/${{ secrets.cf_zone_id }}/purge_cache \
--header 'Content-Type: application/json' \
--header 'X-Auth-Email: ${{ secrets.cf_account_mail }}' \
--header 'Authorization: Bearer ${{ secrets.cf_api_token }}' \
--data '{"purge_everything": true}'
32 changes: 0 additions & 32 deletions .github/workflows/websitebuild.yml

This file was deleted.

10 changes: 10 additions & 0 deletions docs/.vitepress/configs/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ import { align } from "@mdit/plugin-align";
import { imgSize } from "@mdit/plugin-img-size";
import { tabsMarkdownPlugin } from "vitepress-plugin-tabs";
import { emojiRender, defs } from "./emoji";
import { x } from "tinyexec";

export const hostname: string = "https://wotaku.wiki";
export const excludedFiles = ["t.md"];
const GIT_COMMIT =
/** Github actions commit hash */
process.env.GITHUB_SHA ??
/** Commit hash from git */
(await x("git", ["rev-parse", "HEAD"]).then((result) => result.stdout.trim())) ??
"dev";

// @unocss-include
const nav: DefaultTheme.NavItem[] = [
Expand Down Expand Up @@ -348,5 +355,8 @@ export const shared: UserConfig<DefaultTheme.Config> = {
{ icon: "github", link: "https://github.com/wotakumoe/Wotaku" },
{ icon: "discord", link: "https://discord.gg/vShRGx8ZBC" },
],
footer: {
message: `Made with love by <a href="https://github.com/wotakumoe">wotaku</a>. <a href="https://github.com/wotakumoe/Wotaku/commit/${GIT_COMMIT}">Commit: ${GIT_COMMIT.slice(0, 7)}</a>`,
},
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"medium-zoom": "^1.1.0",
"nitro-cors": "^0.7.0",
"nitropack": "^2.9.6",
"tinyexec": "^0.3.0",
"unocss": "0.59.0-beta.1",
"vitepress": "^1.3.4",
"vitepress-plugin-tabs": "^0.5.0",
Expand Down
Loading

0 comments on commit c2db4ce

Please sign in to comment.