bak
This commit is contained in:
parent
aec7f65434
commit
c86772a5dd
14
package-lock.json
generated
14
package-lock.json
generated
@ -9,7 +9,7 @@
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@golevelup/nestjs-rabbitmq": "^1.16.1",
|
||||
"@nestjs-lib/auth": "^0.2.0",
|
||||
"@nestjs-lib/auth": "^0.2.1",
|
||||
"@nestjs/common": "^7.5.1",
|
||||
"@nestjs/config": "^0.6.2",
|
||||
"@nestjs/core": "^7.5.1",
|
||||
@ -2894,9 +2894,9 @@
|
||||
"integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA=="
|
||||
},
|
||||
"node_modules/@nestjs-lib/auth": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.0.tgz",
|
||||
"integrity": "sha512-izveLtKIkE9aBjn0CH85B8XOx4gKzhOEfjH03DVZvh1nWVxUVIv91N1Igxd2unnMPgelucsZ3viyTFJzIz0IGw==",
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.1.tgz",
|
||||
"integrity": "sha512-kGO8iPp69bG1PuTK8k1o0Ew9AZk0O+jhhsvSki9vOMzMYdRe7HMhwjXqdFTsgt2be9actoyA4nafZ/iHAXfqGw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
@ -18836,9 +18836,9 @@
|
||||
"integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA=="
|
||||
},
|
||||
"@nestjs-lib/auth": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.0.tgz",
|
||||
"integrity": "sha512-izveLtKIkE9aBjn0CH85B8XOx4gKzhOEfjH03DVZvh1nWVxUVIv91N1Igxd2unnMPgelucsZ3viyTFJzIz0IGw==",
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.1.tgz",
|
||||
"integrity": "sha512-kGO8iPp69bG1PuTK8k1o0Ew9AZk0O+jhhsvSki9vOMzMYdRe7HMhwjXqdFTsgt2be9actoyA4nafZ/iHAXfqGw==",
|
||||
"requires": {}
|
||||
},
|
||||
"@nestjs/cli": {
|
||||
|
@ -22,7 +22,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@golevelup/nestjs-rabbitmq": "^1.16.1",
|
||||
"@nestjs-lib/auth": "^0.2.0",
|
||||
"@nestjs-lib/auth": "^0.2.1",
|
||||
"@nestjs/common": "^7.5.1",
|
||||
"@nestjs/config": "^0.6.2",
|
||||
"@nestjs/core": "^7.5.1",
|
||||
|
@ -27,6 +27,8 @@ import {
|
||||
getSelfInstanceQueueKey,
|
||||
getSelfInstanceRouteKey,
|
||||
} from '../commons/utils/rabbit-mq';
|
||||
import { unlink } from 'fs/promises';
|
||||
import { rename } from 'fs/promises';
|
||||
|
||||
type Spawn = typeof spawn;
|
||||
|
||||
@ -110,7 +112,7 @@ export class PipelineTaskRunner {
|
||||
|
||||
this.logger.info('running task [%s].', task.id);
|
||||
try {
|
||||
const workspaceRoot = await this.checkout(task);
|
||||
let workspaceRoot = await this.checkout(task);
|
||||
const units = task.units
|
||||
.filter((unit) => unit !== PipelineUnits.checkout)
|
||||
.map(
|
||||
@ -121,6 +123,22 @@ export class PipelineTaskRunner {
|
||||
);
|
||||
this.logger.info({ units }, 'begin run units.');
|
||||
for (const unit of units) {
|
||||
if (unit.type === PipelineUnits.deploy) {
|
||||
const oldRoot = workspaceRoot;
|
||||
workspaceRoot = this.reposService.getDeployRoot(task);
|
||||
if (oldRoot !== workspaceRoot) {
|
||||
await unlink(workspaceRoot).catch(() => void 0);
|
||||
await rename(oldRoot, workspaceRoot);
|
||||
}
|
||||
|
||||
await this.emitEvent(
|
||||
task,
|
||||
unit.type,
|
||||
TaskStatuses.success,
|
||||
`[deploy] change deploy folder content success`,
|
||||
'stdout',
|
||||
);
|
||||
}
|
||||
await this.doTaskUnit(unit.type, unit.scripts, task, workspaceRoot);
|
||||
}
|
||||
await this.emitEvent(
|
||||
|
@ -56,6 +56,14 @@ export class ReposService {
|
||||
);
|
||||
}
|
||||
|
||||
getDeployRoot(task: PipelineTask) {
|
||||
return join(
|
||||
this.configService.get<string>('workspaces.root'),
|
||||
encodeURIComponent(task.pipeline.project.name),
|
||||
encodeURIComponent(`deploy-${task.pipeline.name}`),
|
||||
);
|
||||
}
|
||||
|
||||
async getGit(
|
||||
project: Project,
|
||||
workspaceRoot?: string,
|
||||
|
Loading…
Reference in New Issue
Block a user