forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): save build artifacts to
qwik-build
repository
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { execa } from 'execa'; | ||
|
||
const token = process.env.API_TOKEN_GITHUB; | ||
const repo = `https://${token}:x-oauth-basic@github.com/BuilderIO/qwik-build.git`; | ||
const srcRepoRef = 'https://github.com/BuilderIO/qwik/commit/'; | ||
const root = __dirname + '/..'; | ||
const qwik_build_artifacts = root + '/dist-dev/qwik-build'; | ||
const qwik_package = root + '/dist-dev/@builder.io-qwik'; | ||
|
||
(async () => { | ||
await $('rm', '-rf', qwik_build_artifacts); | ||
const SHA = await $('git', 'rev-parse', 'HEAD'); | ||
process.chdir(`${root}/dist-dev`); | ||
await $('git', 'clone', repo); | ||
const branch = await $('git', 'branch', '--show-current'); | ||
const msg = await $('git', 'log', '--oneline', '-1', '--no-decorate'); | ||
const userName = await $('git', 'log', '-1', "--pretty=format:'%an'"); | ||
const userEmail = await $('git', 'log', '-1', "--pretty=format:'%ae'"); | ||
|
||
process.chdir(`${qwik_build_artifacts}`); | ||
try { | ||
await $('git', 'checkout', branch); | ||
} catch (e) { | ||
await $('git', 'checkout', '-b', branch); | ||
} | ||
await $('rm', '-rf', ...(await expand(qwik_build_artifacts))); | ||
await $('cp', '-r', ...(await expand(qwik_package)), qwik_build_artifacts); | ||
process.chdir(`${qwik_build_artifacts}`); | ||
await $('git', 'add', '--all'); | ||
await $( | ||
'git', | ||
'-c', | ||
`user.name=${userName}`, | ||
'-c', | ||
`user.email=${userEmail}`, | ||
'commit', | ||
'--allow-empty', | ||
'-m', | ||
msg + '\n\n' + srcRepoRef + SHA | ||
); | ||
const dstSHA = await $('git', 'rev-parse', 'HEAD'); | ||
console.log('##############################################################'); | ||
console.log('##############################################################'); | ||
console.log(`### https://github.com/BuilderIO/qwik-build/commit/${dstSHA}`); | ||
console.log('##############################################################'); | ||
console.log('##############################################################'); | ||
await $('git', 'push', repo, `HEAD:${branch}`); | ||
await $('rm', '-rf', qwik_build_artifacts); | ||
})(); | ||
|
||
async function $(cmd: string, ...args: string[]): Promise<string> { | ||
console.log('EXEC:', cmd, ...args); | ||
const { stdout } = await execa(cmd, args); | ||
const output = String(stdout).trim(); | ||
console.log(' ', output); | ||
return output; | ||
} | ||
|
||
async function expand(path: string): Promise<string[]> { | ||
const { stdout } = await execa('ls', [path]); | ||
const paths = String(stdout) | ||
.split('\n') | ||
.map((file) => path + '/' + file.trim()); | ||
return paths; | ||
} |