Skip to content

fix image

fix image #31

Workflow file for this run

# feature-my-homepage 分支推送部署预览
name: Build and Deploy
on:
push:
branches:
- feature-my-homepage
jobs:
build:
name: Build Website
runs-on: windows-latest
steps:
# 检出 Git 仓库
- name: Check out git repository
uses: actions/[email protected]
# 安装 Node.js
- name: Install Node.js
uses: actions/[email protected]
with:
node-version: "18.x"
# 复制环境变量文件
- name: Copy .env.example
run: |
if (-not (Test-Path .env)) {
Copy-Item .env.example .env
} else {
Write-Host ".env file already exists. Skipping the copy step."
}
# 安装项目依赖
- name: Install Dependencies
run: npm install
# 构建程序
- name: Build Website
run: npm run build
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 上传构建产物
- name: Upload artifacts
# 链接 https://github.com/actions/upload-artifact/
uses: actions/[email protected]
with:
name: Homepage
path: dist
# TODO 以下是自动化将打包的静态页面部署到 gh-pages 分支和我自己服务器的脚本
# 为了互不影响,采用并行执行的方式
deploy-gh-pages:
name: Deploy to gh-pages
runs-on: ubuntu-latest
needs: build # 表示依赖于 build 作业完成
steps:
- name: Download artifact
# 链接 https://github.com/actions/download-artifact
uses: actions/[email protected]
with:
name: Homepage
path: dist
- name: Deploy to gh-pages-deprecated
# 链接 https://github.com/crazy-max/ghaction-github-pages/
uses: crazy-max/[email protected]
with:
target_branch: gh-pages-deprecated
build_dir: dist
keep_history: true
# fqdn: xxx 自定义域名
allow_empty_commit: false
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
deploy-server:
name: Deploy to My Own Server
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: Homepage
path: public
- name: Deploy to My Own Server
# 链接 https://github.com/easingthemes/ssh-deploy
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ARGS: "-avzr --times --update --delete"
SOURCE: "public/"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.TARGET }}