Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
autoactions committed Dec 23, 2024
1 parent 3e4bc4e commit 87511a4
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/optimize-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:

- name: Sync with upstream
id: sync
continue-on-error: true
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
Expand All @@ -49,37 +48,35 @@ jobs:
if git rev-list HEAD..upstream/main --count | grep -q "^0$"; then
echo "sync_status=uptodate" >> $GITHUB_OUTPUT
echo "仓库已是最新,无需同步"
else
# 重置到上游状态
git reset --hard upstream/main
# 强制推送更新
git push origin HEAD:test -f
echo "sync_status=success" >> $GITHUB_OUTPUT
exit 0
fi
# 重置到上游状态
git reset --hard upstream/main
# 强制推送更新
git push origin HEAD:test -f
echo "sync_status=updated" >> $GITHUB_OUTPUT
- name: Check sync status
if: steps.sync.outputs.sync_status == 'failed'
run: |
echo "同步上游仓库失败,请手动解决冲突"
exit 1
# 只有当仓库不是最新且同步成功时,才继续执行后续步骤
- name: Setup Node.js
if: steps.sync.outputs.sync_status == 'updated'
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

# 优化 FFmpeg 缓存
- name: Cache FFmpeg
if: steps.sync.outputs.sync_status == 'updated'
id: cache-ffmpeg
uses: actions/cache@v4
with:
path: ~/ffmpeg
key: ${{ runner.os }}-ffmpeg-static-${{ env.FFMPEG_VERSION }}

- name: Install FFmpeg
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
if: steps.sync.outputs.sync_status == 'updated' && steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
mkdir -p ~/ffmpeg
wget -q https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
Expand All @@ -89,10 +86,12 @@ jobs:
rm -rf ffmpeg-*-amd64-static*
- name: Add FFmpeg to PATH
if: steps.sync.outputs.sync_status == 'updated'
run: echo "$HOME/ffmpeg" >> $GITHUB_PATH

# 添加 node_modules 缓存
- name: Cache node_modules
if: steps.sync.outputs.sync_status == 'updated'
id: cache-node-modules
uses: actions/cache@v4
with:
Expand All @@ -102,10 +101,11 @@ jobs:
${{ runner.os }}-node-modules-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
if: steps.sync.outputs.sync_status == 'updated' && steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci

- name: Optimize Assets
if: steps.sync.outputs.sync_status == 'updated'
id: optimize_assets
continue-on-error: true
run: |
Expand All @@ -115,12 +115,13 @@ jobs:
wait
- name: Check Optimization Status
if: steps.optimize_assets.outcome == 'failure'
if: steps.sync.outputs.sync_status == 'updated' && steps.optimize_assets.outcome == 'failure'
run: |
echo "资源优化过程中出现错误,请检查日志"
exit 1
- name: Check for changes
if: steps.sync.outputs.sync_status == 'updated'
id: check_changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
Expand All @@ -130,7 +131,7 @@ jobs:
fi
- name: Commit and push if changed
if: steps.check_changes.outputs.changes == 'true' && steps.sync.outputs.sync_status == 'success'
if: steps.sync.outputs.sync_status == 'updated' && steps.check_changes.outputs.changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
Expand Down

0 comments on commit 87511a4

Please sign in to comment.