Skip to content

Commit

Permalink
Create css-compress.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
caolib authored Dec 18, 2024
1 parent 6c0b19d commit 1c270f8
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/css-compress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Compress CSS Files

on:
push:
branches:
- onelight # 监听的分支,可以改成你的目标分支

jobs:
build:
runs-on: ubuntu-latest

steps:
# 1. 检出代码
- name: Checkout repository
uses: actions/checkout@v3

# 2. 设置 Node.js 环境(安装依赖)
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18 # 使用 Node.js 版本,可根据需要调整

# 3. 安装 clean-css-cli
- name: Install clean-css-cli
run: |
npm install -g clean-css-cli
# 4. 压缩 CSS 文件并保存到 dist 文件夹
- name: Compress CSS files
run: |
mkdir -p dist
cleancss -o ./dist/onelight.user.min.css ./onelight.user.css
cleancss -o ./dist/onelight.min.css ./onelight.css
# 5. 推送压缩后的文件到仓库
- name: Commit and push compressed files
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add dist/
git commit -m "Add compressed CSS files"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 1c270f8

Please sign in to comment.