更新 config #91
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 Icon Library | |
on: | |
push: | |
branches: | |
- main | |
# 只有指定文件变化才运行 | |
# paths: | |
# - package.json | |
# 允许你从 Actions 选项卡手动运行此工作流程 | |
workflow_dispatch: | |
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages | |
permissions: | |
contents: write | |
jobs: | |
# 构建工作 | |
deploy: | |
runs-on: ubuntu-latest | |
name: Deploy | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# 修复时间戳 | |
- name: Restore timestamps | |
uses: chetan/git-restore-mtime-action@v2 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'yarn' | |
- name: Install dependencies and build | |
run: | | |
yarn install | |
yarn build:icons | |
yarn build:code | |
yarn build | |
# 检查版本 | |
- name: Check version changes | |
uses: EndBug/version-check@v2 | |
id: check | |
with: | |
diff-search: true | |
file-url: https://unpkg.com/ksw-vue-icon@latest/package.json | |
static-checking: localIsNew | |
# check是我们在上一段中为check步骤提供的id | |
- name: Version update detected | |
if: steps.check.outputs.changed == 'true' | |
run: 'echo "发现版本更改!新版本: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"' | |
# 发布到 NPM | |
- name: Publish the package to NPM | |
if: steps.check.outputs.changed == 'true' | |
run: yarn clean-publish | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
# 部署 GitHub Pages | |
- name: Deploy GitHub Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: dist | |
git-config-name: GitHubActions | |
git-config-email: [email protected] | |
continue-on-error: true # 即使失败,也继续下一个步骤 | |
# 部署到 Centos 服务器 | |
- name: Deploy to Centos server | |
uses: easingthemes/ssh-deploy@main | |
with: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
ARGS: "-rlgoDzvc -i --delete" | |
SOURCE: "dist/" | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
REMOTE_PORT: ${{ secrets.REMOTE_PORT }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
TARGET: ${{ secrets.REMOTE_TARGET }} | |
EXCLUDE: "/dist/, /node_modules/" | |
SCRIPT_BEFORE: | | |
whoami | |
ls -al | |
SCRIPT_AFTER: | | |
whoami | |
ls -al | |
echo $RSYNC_STDOUT | |
continue-on-error: true # 即使失败,也继续下一个步骤 | |
- name: Set short git commit SHA | |
id: vars | |
run: | | |
calculatedSha=$(git rev-parse --short ${{ github.sha }}) | |
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV | |
# 发送企业微信通知 | |
- name: WeChat Work notification | |
if: steps.check.outputs.changed == 'true' | |
uses: chf007/action-wechat-work@master | |
env: | |
WECHAT_WORK_BOT_WEBHOOK: ${{secrets.WECHAT_WORK_BOT_WEBHOOK}} | |
with: | |
msgtype: markdown | |
content: "兄弟们,咱们的图标更新 <font color=\"warning\">${{ steps.check.outputs.version }}</font> 啦!\n | |
> 变更日志 [${{ env.COMMIT_SHORT_SHA }}](https://github.com/${{github.repository}}/commit/${{github.sha}})\n | |
> <font color=\"comment\">${{ github.event.head_commit.message }}</font>\n\n | |
[在线查看图标](https://sengoku-f.github.io/KSW-vue-icon/)" | |
- name: WeChat Work notification 2 | |
if: steps.check.outputs.changed == 'true' | |
uses: chf007/action-wechat-work@master | |
env: | |
WECHAT_WORK_BOT_WEBHOOK: ${{secrets.WECHAT_WORK_BOT_WEBHOOK}} | |
with: | |
msgtype: text | |
content: "yarn upgrade ksw-vue-icon --latest" |