From b0c62de391536bd1cf8a5c424b540f0778f008bb Mon Sep 17 00:00:00 2001 From: Leon Xu Date: Sun, 29 Nov 2026 14:53:35 -0800 Subject: [PATCH] Fold lint into build job to avoid duplicate dependency install --- .gitea/workflows/deploy.yml | 28 ++++++---------------------- README.md | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 550682c..d7a67b8 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -6,28 +6,9 @@ on: workflow_dispatch: jobs: - # ------------------------------------------------------------ style checks - # Runs in parallel with build; both must pass before the site is tested. - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - - - name: Install dependencies - run: yarn install --frozen-lockfile - - - name: Lint Markdown - run: npx markdownlint-cli2 - # ------------------------------------------------------------ build - # Produces the static site once and shares it as an artifact so the - # test and deploy stages never rebuild. + # Single dependency install serves both the lint check and the build. + # Lint failures fail this job, which gates test and deploy. build: runs-on: ubuntu-latest steps: @@ -45,6 +26,9 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile + - name: Lint Markdown + run: npx markdownlint-cli2 + - name: Build site run: hexo generate @@ -69,7 +53,7 @@ jobs: # Validates the built site locally. Never touches production. Deploy # physically cannot run unless this job passes. test: - needs: [lint, build] + needs: build runs-on: ubuntu-latest steps: - name: Download site artifact diff --git a/README.md b/README.md index 44a53a3..9b684e2 100644 --- a/README.md +++ b/README.md @@ -87,19 +87,21 @@ git commit -m "new post" git push origin master ``` -The [deploy workflow](.gitea/workflows/deploy.yml) runs four gated stages: +The [deploy workflow](.gitea/workflows/deploy.yml) runs three gated stages: -1. **lint** — checks all Markdown in `source/` and `scaffolds/` with - `markdownlint-cli2` (house style codified in `.markdownlint-cli2.jsonc`) -2. **build** — checks out the repo, sets up Node 22, runs `yarn install - --frozen-lockfile` and `hexo generate`, optimizes every PNG/JPEG in the - built output with pngquant/oxipng/jpegoptim (~58% smaller images, originals - in `source/` untouched), then uploads the site as a workflow artifact -3. **test** — validates the built artifact without touching production: +1. **build** — checks out the repo, sets up Node 22, and runs a single + `yarn install --frozen-lockfile` that serves both jobs of this stage: + first it lints all Markdown in `source/` and `scaffolds/` with + `markdownlint-cli2` (house style codified in `.markdownlint-cli2.jsonc`; + lint failures fail the stage), then runs `hexo generate` and optimizes + every PNG/JPEG in the built output with pngquant/jpegoptim (~56% smaller + images, originals in `source/` untouched). The site is uploaded as a + workflow artifact +2. **test** — validates the built artifact without touching production: structural checks (index, theme assets, file count) plus a serving smoke test that requests the homepage, a real post page, and the stylesheet over a local HTTP server -4. **deploy** — only runs if lint, build, and test all passed; downloads the +3. **deploy** — only runs if build and test both passed; downloads the tested artifact, writes an SSH deploy key from the `DEPLOY_KEY` secret, and `rsync -avz` over SSH (key-based only; the server rejects password auth) to `root@69.164.253.99:/www/wwwroot/leonxu260.dev/`