mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-05 01:44:24 +08:00
84 lines
2.6 KiB
YAML
84 lines
2.6 KiB
YAML
name: Build Frontend Assets
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build-and-commit:
|
|
name: Build frontend assets
|
|
runs-on: ubuntu-latest
|
|
if: "!startsWith(github.event.head_commit.message, 'build:')"
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: .dev
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: "lts/*"
|
|
|
|
- name: Enable Corepack and use latest pnpm
|
|
run: |
|
|
corepack enable
|
|
corepack use pnpm@latest
|
|
echo "pnpm version: $(pnpm --version)"
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build frontend assets
|
|
run: pnpm build
|
|
|
|
- name: Check for build output changes
|
|
id: check-changes
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
if [ -n "$(git status --porcelain htdocs/)" ]; then
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
echo "📦 Changes detected in htdocs/:"
|
|
git status --short htdocs/
|
|
else
|
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
echo "✅ No changes in build output"
|
|
fi
|
|
|
|
- name: Generate build report
|
|
if: steps.check-changes.outputs.has_changes == 'true'
|
|
id: build-report
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
echo "Changed Files:" > /tmp/build-report.txt
|
|
git diff --name-status htdocs/ | sed 's/^/ - /' >> /tmp/build-report.txt
|
|
echo "" >> /tmp/build-report.txt
|
|
echo "Build Size:" >> /tmp/build-report.txt
|
|
ls -lh htdocs/luci-static/aurora/main.css htdocs/luci-static/resources/view/aurora/sysauth.js htdocs/luci-static/resources/menu-aurora.js 2>/dev/null | awk '{size=$5; if(size ~ /^[0-9]+$/ && size < 1024) size=size"B"; printf " - %-53s %s\n", $9, size}' >> /tmp/build-report.txt
|
|
cat /tmp/build-report.txt
|
|
|
|
- name: Commit and push build outputs
|
|
if: steps.check-changes.outputs.has_changes == 'true'
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add htdocs/ .dev/package.json
|
|
{
|
|
echo "build: update frontend assets"
|
|
echo ""
|
|
cat /tmp/build-report.txt
|
|
} | git commit -F -
|
|
git push
|