Merge branch 'main' of https://github.com/qzqzcsclub/csclubweb #89
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: Deploy # 部署 | |
on: # 触发条件 | |
push: | |
branches: | |
- main # 推送到 main 分支(这里的分支名很重要,不要弄错了) | |
release: | |
types: | |
- published # 推送新版本号 | |
workflow_dispatch: # 手动触发 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout # Checkout 仓库 | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
- name: Setup Node # 安装 Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "16.x" | |
- name: Install Hexo # 安装 Hexo | |
run: | | |
npm install hexo-cli -g | |
- name: Cache Modules # 缓存 Node 插件 | |
uses: actions/cache@v1 | |
id: cache-modules | |
with: | |
path: node_modules | |
key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}} | |
- name: Install Dependencies # 如果没有缓存或 插件有更新,则安装插件 | |
if: steps.cache-modules.outputs.cache-hit != 'true' | |
run: | # **如果仓库里没有 package-lock.json,上传一下,npm ci 必须要有 package-lock.json** | |
npm set registry https://registry.npm.taobao.org/ | |
npm ci | |
- name: Generate # 生成 | |
run: | | |
hexo clean | |
hexo generate | |
- name: Deploy # 部署 | |
run: | | |
cd ./public | |
git init | |
git config --global user.name 'qzcsclub' | |
git config --global user.email '[email protected]' | |
git add . | |
git commit -m "${{ github.event.head_commit.message }} $(date +"%Z %Y-%m-%d %A %H:%M:%S") Updated By Github Actions" | |
git push --force --quiet "https://qzcsclub:${{ secrets.GITH_TOKEN }}@github.com/qzcsclub/qzcsclub.github.io.git" master:main | |
# 以下部分为部署站点到服务器的代码,因为社团服务器到期就注释掉了,以后有需要可以启用。 | |
# USER_HOST为服务器ip,USER_NAME为服务器登录用户名,USER_PASS为服务器登录密码,VPS_SITE为站点路径,这些千万不要直接在下面替换掉(防止泄露),应在github的action的secret设置 | |
# git push --force --quiet "https://qzcsclub:${{ secrets.GITEE_TOKEN }}@gitee.com/qzcsclub/csclubweb.git" master:main | |
# # 请先在服务器配置git | |
# - name: VPS clone Gitee # 连接服务器并克隆Gitee | |
# uses: cross-the-world/ssh-pipeline@master | |
# env: | |
# WELCOME: "ssh pipeline" | |
# with: | |
# host: ${{ secrets.USER_HOST }} | |
# user: ${{ secrets.USER_NAME }} | |
# pass: ${{ secrets.USER_PASS }} | |
# connect_timeout: 10s | |
# script: | | |
# cd ${{ secrets.VPS_SITE }} | |
# rm -rf csclubweb | |
# git clone https://gitee.com/qzcsclub/csclubweb.git |