mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-02-04 04:43:10 +00:00
fix(workflow): 修复低级错误
This commit is contained in:
parent
609c910d5a
commit
1d7e9cb6d8
125
.github/workflows/build-and-pr.yml
vendored
125
.github/workflows/build-and-pr.yml
vendored
@ -3,7 +3,7 @@ name: Build and Create PR
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch: # 手动触发
|
workflow_dispatch: # 手动触发
|
||||||
push:
|
push:
|
||||||
branches: [ main, pr/* ]
|
branches: [main, pr/*]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -26,83 +26,84 @@ jobs:
|
|||||||
output: precompiled/app
|
output: precompiled/app
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '18'
|
node-version: '18'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
npm install -g pnpm
|
npm install -g pnpm
|
||||||
pnpm install
|
pnpm install
|
||||||
|
|
||||||
- name: Build for ${{ matrix.platform }}
|
- name: Build for ${{ matrix.platform }}
|
||||||
run: |
|
run: |
|
||||||
npm run pkg${{ matrix.platform }}
|
npm run pkg${{ matrix.platform }}
|
||||||
env:
|
env:
|
||||||
PKG_TARGET: ${{ matrix.target }}
|
PKG_TARGET: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: app-${{ matrix.platform }}
|
name: app-${{ matrix.platform }}
|
||||||
path: ${{ matrix.output }}
|
path: ${{ matrix.output }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
create-pr:
|
create-pr:
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name == 'workflow_dispatch' # 只在手动触发时创建PR
|
if: github.event_name == 'workflow_dispatch' # 只在手动触发时创建PR
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download all artifacts
|
- name: Download all artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: precompiled
|
path: precompiled
|
||||||
|
|
||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
run: ls -R
|
run: ls -R
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
|
|
||||||
- name: Create new branch and commit
|
- name: Create new branch and commit
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name 'github-actions[bot]'
|
git config --global user.name 'github-actions[bot]'
|
||||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||||
|
|
||||||
BRANCH_NAME="auto-build-$(date +%Y%m%d-%H%M%S)"
|
BRANCH_NAME="auto-build-$(date +%Y%m%d-%H%M%S)"
|
||||||
git checkout -b $BRANCH_NAME
|
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
|
||||||
|
git checkout -b $BRANCH_NAME
|
||||||
|
|
||||||
# 复制并整理下载的文件
|
# 复制并整理下载的文件
|
||||||
mkdir -p precompiled
|
mkdir -p precompiled
|
||||||
cp app-win/* precompiled/ || true
|
cp app-win/* precompiled/ || true
|
||||||
cp app-linux/* precompiled/ || true
|
cp app-linux/* precompiled/ || true
|
||||||
cp app-macos/* precompiled/ || true
|
cp app-macos/* precompiled/ || true
|
||||||
|
|
||||||
# 提交更改
|
# 提交更改
|
||||||
git add precompiled/
|
git add precompiled/
|
||||||
git commit -m "Auto-build: Add compiled binaries for win, linux, macos" || exit 0
|
git commit -m "Auto-build: Add compiled binaries for win, linux, macos" || exit 0
|
||||||
|
|
||||||
# 推送到远程仓库
|
# 推送到远程仓库
|
||||||
git push origin $BRANCH_NAME
|
git push origin $BRANCH_NAME
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const { data: pullRequest } = await github.rest.pulls.create({
|
const { data: pullRequest } = await github.rest.pulls.create({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
title: 'Auto-build: Add compiled binaries for win, linux, macos',
|
title: 'Auto-build: Add compiled binaries for win, linux, macos',
|
||||||
head: `auto-build-${new Date().toISOString().slice(0, 19).replace(/[-:]/g, '').replace('T', '-')}`,
|
head: '${{ env.BRANCH_NAME }}',
|
||||||
base: 'main',
|
base: 'main',
|
||||||
body: 'This PR contains newly built binaries for Windows, Linux, and macOS platforms.'
|
body: 'This PR contains newly built binaries for Windows, Linux, and macOS platforms.'
|
||||||
});
|
});
|
||||||
console.log(`Created PR #${pullRequest.number}: ${pullRequest.html_url}`);
|
console.log(`Created PR #${pullRequest.number}: ${pullRequest.html_url}`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user