mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
CI: only run deploy if build actually finished
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import process from 'node:process';
|
||||
import os from 'node:os';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import { downloadPreviousBuild } from './download-previous-build';
|
||||
import { buildCommon } from './build-common';
|
||||
@@ -28,6 +29,7 @@ import { buildCloudMounterRules } from './build-cloudmounter-rules';
|
||||
import { createSpan, printTraceResult, whyIsNodeRunning } from './trace';
|
||||
import { buildDeprecateFiles } from './build-deprecate-files';
|
||||
import { cacheGc } from './lib/make-fetch-happen';
|
||||
import path from 'node:path';
|
||||
|
||||
process.on('uncaughtException', (error) => {
|
||||
console.error('Uncaught exception:', error);
|
||||
@@ -38,6 +40,8 @@ process.on('unhandledRejection', (reason) => {
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
const buildFinishedLock = path.join(__dirname, '../.BUILD_FINISHED');
|
||||
|
||||
(async () => {
|
||||
console.log('Version:', process.version);
|
||||
|
||||
@@ -60,6 +64,10 @@ process.on('unhandledRejection', (reason) => {
|
||||
|
||||
const rootSpan = createSpan('root');
|
||||
|
||||
if (fs.existsSync(buildFinishedLock)) {
|
||||
fs.unlinkSync(buildFinishedLock);
|
||||
}
|
||||
|
||||
try {
|
||||
const downloadPreviousBuildPromise = downloadPreviousBuild(rootSpan);
|
||||
const buildCommonPromise = downloadPreviousBuildPromise.then(() => buildCommon(rootSpan));
|
||||
@@ -97,6 +105,9 @@ process.on('unhandledRejection', (reason) => {
|
||||
|
||||
printTraceResult(rootSpan.traceResult);
|
||||
|
||||
// write a file to demonstrate that the build is finished
|
||||
fs.writeFileSync(buildFinishedLock, 'BUILD_FINISHED\n');
|
||||
|
||||
// Finish the build to avoid leaking timer/fetch ref
|
||||
await whyIsNodeRunning();
|
||||
process.exit(0);
|
||||
|
||||
Reference in New Issue
Block a user