Skip to content

Commit

Permalink
ci: add github action yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ozline committed Jun 4, 2024
1 parent c79ca1d commit 46b6431
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 8 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on

jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build website
run: yarn build

- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: build

deploy:
name: Deploy to GitHub Pages
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
26 changes: 26 additions & 0 deletions .github/workflows/test-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test deployment

on:
pull_request:
branches:
- main
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on

jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Test build website
run: yarn build
17 changes: 9 additions & 8 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';

const config: Config = {
title: 'My Site',
tagline: 'Dinosaurs are cool',
title: 'west2-online',
tagline: '福州大学西二在线工作室',
favicon: 'img/favicon.ico',

// Set the production url of your site here
url: 'https://your-docusaurus-site.example.com',
url: 'https://site.west2.online',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'facebook', // Usually your GitHub org/user name.
projectName: 'docusaurus', // Usually your repo name.
organizationName: 'west2-online', // Github Organization 名称
projectName: 'website', // 仓库名称
deploymentBranch: 'gh-pages', // 部署分支
trailingSlash: false, // 是否保留尾部斜杠

onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
Expand All @@ -25,8 +26,8 @@ const config: Config = {
// useful metadata like html lang. For example, if your site is Chinese, you
// may want to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
defaultLocale: 'zh-Hans',
locales: ['zh-Hans'],
},

presets: [
Expand Down

0 comments on commit 46b6431

Please sign in to comment.