Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 committed Jan 21, 2025
1 parent 3d53065 commit 458b324
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-tdesign-vue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: test
uses: ./
id: test
Expand Down
53 changes: 53 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30161,6 +30161,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports["default"] = run;
const core_1 = __nccwpck_require__(9999);
const exec_1 = __nccwpck_require__(8872);
const git_1 = __importDefault(__nccwpck_require__(8511));
const github_1 = __importDefault(__nccwpck_require__(9764));
const supportTrigger = ['/update-common', '/update-snapshot'];
function run(context) {
Expand All @@ -30174,6 +30176,38 @@ function run(context) {
if (!prData.maintainer_can_modify) {
(0, core_1.error)(`pr:${context.pr_number} 不允许维护者修改`);
}
if (prData.state !== 'open') {
(0, core_1.error)(`pr:${context.pr_number} 不是 open 状态`);
}
let isForkPr = false;
if (prData.head.user.login !== context.owner) {
isForkPr = true;
(0, core_1.info)(`pr:${context.pr_number} 是 fork pr`);
}
const branchName = prData.head.ref;
const { cloneRepo, initSubmodule, checkoutBranch, checkoutPr, addRemote } = (0, git_1.default)({
repo: context.repo,
owner: context.owner,
token: context.token,
});
yield cloneRepo();
if (isForkPr) {
yield addRemote('pr', prData.base.repo.clone_url);
yield checkoutPr(context.pr_number);
yield (0, exec_1.exec)('git', [
'branch',
'--set-upstream-to',
`refs/remotes/pr/${prData.head.ref}`,
`pr-${context.pr_number}`,
], { cwd: `../${context.repo}` });
}
else {
yield checkoutBranch(branchName);
}
yield initSubmodule();
yield (0, exec_1.exec)('npm', ['install'], { cwd: `../${context.repo}` });
yield (0, exec_1.exec)('npm', ['run', 'test:update'], { cwd: `../${context.repo}` });
yield (0, exec_1.exec)('git', ['status'], { cwd: `../${context.repo}` });
});
}

Expand Down Expand Up @@ -30334,6 +30368,17 @@ function useGit(context) {
yield (0, exec_1.exec)('git', ['checkout', '-b', branch], { cwd: `../${context.repo}` });
});
}
function checkoutBranch(branch) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, exec_1.exec)('git', ['checkout', branch], { cwd: `../${context.repo}` });
});
}
function checkoutPr(pr_number) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, exec_1.exec)('git', ['fetch', 'origin', `pull/${pr_number}/head:pr-${pr_number}`], { cwd: `../${context.repo}` });
yield (0, exec_1.exec)('git', ['checkout', `pr-${pr_number}`], { cwd: `../${context.repo}` });
});
}
function gitCommit(message) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, exec_1.exec)(`git commit -am "${message}" --no-verify`, [], { cwd: `../${context.repo}` });
Expand All @@ -30360,14 +30405,22 @@ function useGit(context) {
return !stdout.includes('nothing to commit, working tree clean');
});
}
function addRemote(origin, gitUrl) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, exec_1.exec)('git', ['remote', 'add', origin, gitUrl], { cwd: `../${context.repo}` });
});
}
return {
checkoutPr,
cloneRepo,
createBranch,
gitCommit,
gitPush,
initSubmodule,
updateSubmodule,
isNeedCommit,
checkoutBranch,
addRemote,
};
}

Expand Down
12 changes: 10 additions & 2 deletions src/tdesign/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ export default async function run(context: TriggerContext) {
await cloneRepo()

if (isForkPr) {
await checkoutPr(context.pr_number)
await addRemote('pr', prData.base.repo.clone_url)
await exec('git', ['fetch', 'pr'], { cwd: `../${context.repo}` })
await checkoutPr(context.pr_number)
await exec('git', [
'branch',
'--set-upstream-to',
`refs/remotes/pr/${prData.head.ref}`,
`pr-${context.pr_number}`,
], { cwd: `../${context.repo}` })
}
else {
await checkoutBranch(branchName)
}
await initSubmodule()
await exec('npm', ['install'], { cwd: `../${context.repo}` })
await exec('npm', ['run', 'test:update'], { cwd: `../${context.repo}` })
await exec('git', ['status'], { cwd: `../${context.repo}` })
}

0 comments on commit 458b324

Please sign in to comment.