fix for main origin 575a5adbeff0b46390fb08901c7166649255204c

This commit is contained in:
gandc committed 2026-10-11 03:11:48 +03:00
1 parent 703bf076e2
commit eef54a61cc
11 files changed
+1008 -703

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import {spawnSync} from 'node:child_process';
import {appendFileSync, existsSync, mkdirSync, readFileSync} from 'node:fs';
import {resolve} from 'node:path';
const source = resolve('fluxer-src');
function git(...args) {
const result = spawnSync('git', args, {encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit']});
if (result.error) throw result.error;
if (result.status !== 0) throw new Error(`git ${args[0]} failed (${result.status})`);
if (result.stdout) process.stdout.write(result.stdout);
return result.stdout.trim();
}
// checkout cleans the job workspace; never reuse a source tree from a previous run.
if (existsSync(source)) throw new Error(`Source directory already exists: ${source}`);
mkdirSync(source);
git('-C', source, 'init');
git('-C', source, 'config', 'core.autocrlf', 'false');
git('-C', source, 'remote', 'add', 'origin', 'https://github.com/fluxerapp/fluxer.git');
const ref = process.env.UPSTREAM_SHA || 'main';
if (ref !== 'main' && !/^[0-9a-f]{40}$/.test(ref)) throw new Error('UPSTREAM_SHA must be a full commit SHA');
git('-C', source, 'fetch', '--depth=1', 'origin', ref);
git('-C', source, 'checkout', '--detach', 'FETCH_HEAD');
const sha = git('-C', source, 'rev-parse', 'HEAD');
const packageManager = JSON.parse(readFileSync(resolve(source, 'package.json'), 'utf8')).packageManager;
console.log(`Fluxer revision: ${sha}; package manager: ${packageManager}`);
if (process.env.GITHUB_OUTPUT) appendFileSync(process.env.GITHUB_OUTPUT, `sha=${sha}\n`);
if (process.env.GITHUB_ENV) appendFileSync(process.env.GITHUB_ENV, `WORKDIR=${source}\n`);