mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-11 16:50:33 +08:00
CI: only run deploy if build actually finished
This commit is contained in:
parent
317d914086
commit
e43ba55357
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@ -68,6 +68,10 @@ jobs:
|
|||||||
echo "public directory is empty"
|
echo "public directory is empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if [ ! -f .BUILD_FINISHED ]; then
|
||||||
|
echo ".BUILD_FINISHED not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build-artifact-${{ github. ref_name }}
|
name: build-artifact-${{ github. ref_name }}
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ node_modules
|
|||||||
.cache
|
.cache
|
||||||
public
|
public
|
||||||
tmp.*
|
tmp.*
|
||||||
|
.BUILD_FINISHED
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
import { downloadPreviousBuild } from './download-previous-build';
|
import { downloadPreviousBuild } from './download-previous-build';
|
||||||
import { buildCommon } from './build-common';
|
import { buildCommon } from './build-common';
|
||||||
@ -28,6 +29,7 @@ import { buildCloudMounterRules } from './build-cloudmounter-rules';
|
|||||||
import { createSpan, printTraceResult, whyIsNodeRunning } from './trace';
|
import { createSpan, printTraceResult, whyIsNodeRunning } from './trace';
|
||||||
import { buildDeprecateFiles } from './build-deprecate-files';
|
import { buildDeprecateFiles } from './build-deprecate-files';
|
||||||
import { cacheGc } from './lib/make-fetch-happen';
|
import { cacheGc } from './lib/make-fetch-happen';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
process.on('uncaughtException', (error) => {
|
process.on('uncaughtException', (error) => {
|
||||||
console.error('Uncaught exception:', error);
|
console.error('Uncaught exception:', error);
|
||||||
@ -38,6 +40,8 @@ process.on('unhandledRejection', (reason) => {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const buildFinishedLock = path.join(__dirname, '../.BUILD_FINISHED');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
console.log('Version:', process.version);
|
console.log('Version:', process.version);
|
||||||
|
|
||||||
@ -60,6 +64,10 @@ process.on('unhandledRejection', (reason) => {
|
|||||||
|
|
||||||
const rootSpan = createSpan('root');
|
const rootSpan = createSpan('root');
|
||||||
|
|
||||||
|
if (fs.existsSync(buildFinishedLock)) {
|
||||||
|
fs.unlinkSync(buildFinishedLock);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const downloadPreviousBuildPromise = downloadPreviousBuild(rootSpan);
|
const downloadPreviousBuildPromise = downloadPreviousBuild(rootSpan);
|
||||||
const buildCommonPromise = downloadPreviousBuildPromise.then(() => buildCommon(rootSpan));
|
const buildCommonPromise = downloadPreviousBuildPromise.then(() => buildCommon(rootSpan));
|
||||||
@ -97,6 +105,9 @@ process.on('unhandledRejection', (reason) => {
|
|||||||
|
|
||||||
printTraceResult(rootSpan.traceResult);
|
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
|
// Finish the build to avoid leaking timer/fetch ref
|
||||||
await whyIsNodeRunning();
|
await whyIsNodeRunning();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user