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"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f .BUILD_FINISHED ]; then
|
||||
echo ".BUILD_FINISHED not found"
|
||||
exit 1
|
||||
fi
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-artifact-${{ github. ref_name }}
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ node_modules
|
||||
.cache
|
||||
public
|
||||
tmp.*
|
||||
.BUILD_FINISHED
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user