mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
feat: generalized asset repo
This commit is contained in:
1 parent
0f7d682782
commit
4a04f8a8f3
5 files changed
+14
-9
No files matched your search
@@ -0,0 +1 @@
|
||||
export const ASSETS_REPO = 'blitzkrieg-assets';
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ASSETS_REPO } from '../../constants/assets';
|
||||
import isDev from './isDev';
|
||||
|
||||
export function asset(path: string) {
|
||||
return `https://raw.githubusercontent.com/tresabhi/blitzkrieg-assets/${isDev() ? 'dev' : 'main'}/${path}`;
|
||||
return `https://raw.githubusercontent.com/tresabhi/${ASSETS_REPO}/${isDev() ? 'dev' : 'main'}/${path}`;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ASSETS_REPO } from '../../constants/assets';
|
||||
import commitMultipleFiles, { FileChange } from './commitMultipleFiles';
|
||||
|
||||
export async function commitAssets(
|
||||
@@ -12,7 +13,7 @@ export async function commitAssets(
|
||||
|
||||
await commitMultipleFiles(
|
||||
'tresabhi',
|
||||
'blitzkrieg-assets',
|
||||
ASSETS_REPO,
|
||||
production ? 'main' : 'dev',
|
||||
`${message} - ${new Date().toDateString()}`,
|
||||
changes,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ASSETS_REPO } from '../../constants/assets';
|
||||
import getRatingInfo from '../blitz/getRatingInfo';
|
||||
|
||||
interface GitHubTrees {
|
||||
@@ -16,7 +17,7 @@ export async function getArchivedLatestSeasonNumber() {
|
||||
if (ratingInfo.detail) {
|
||||
const regionsURL = (
|
||||
(await fetch(
|
||||
'https://api.github.com/repos/tresabhi/blitzkrieg-assets/git/trees/main',
|
||||
`https://api.github.com/repos/tresabhi/${ASSETS_REPO}/git/trees/main`,
|
||||
).then((response) => response.json())) as GitHubTrees
|
||||
).tree.find(({ path }) => path === 'regions')!.url;
|
||||
const comURL = (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ASSETS_REPO } from '../../constants/assets';
|
||||
import { GithubChangeBlob, createBlob } from '../blitzrinth/createBlob';
|
||||
import { octokit } from '../blitzrinth/octokit';
|
||||
|
||||
@@ -11,7 +12,7 @@ export class AssetCommit {
|
||||
async add(path: string, content: string, encoding: 'utf-8' | 'base64') {
|
||||
console.log(`Blob: adding ${path}...`);
|
||||
|
||||
const blob = await createBlob('tresabhi', 'blitzkrieg-assets', {
|
||||
const blob = await createBlob('tresabhi', ASSETS_REPO, {
|
||||
content,
|
||||
encoding,
|
||||
path,
|
||||
@@ -26,14 +27,14 @@ export class AssetCommit {
|
||||
const latestCommitSha = (
|
||||
await octokit.git.getRef({
|
||||
owner: 'tresabhi',
|
||||
repo: 'blitzkrieg-assets',
|
||||
repo: ASSETS_REPO,
|
||||
ref: `heads/${this.production ? 'main' : 'dev'}`,
|
||||
})
|
||||
).data.object.sha;
|
||||
const treeSha = (
|
||||
await octokit.git.getCommit({
|
||||
owner: 'tresabhi',
|
||||
repo: 'blitzkrieg-assets',
|
||||
repo: ASSETS_REPO,
|
||||
commit_sha: latestCommitSha,
|
||||
})
|
||||
).data.tree.sha;
|
||||
@@ -41,20 +42,20 @@ export class AssetCommit {
|
||||
|
||||
const { data: treeData } = await octokit.git.createTree({
|
||||
owner: 'tresabhi',
|
||||
repo: 'blitzkrieg-assets',
|
||||
repo: ASSETS_REPO,
|
||||
base_tree: treeSha,
|
||||
tree: blobs,
|
||||
});
|
||||
const { data: newCommitData } = await octokit.git.createCommit({
|
||||
owner: 'tresabhi',
|
||||
repo: 'blitzkrieg-assets',
|
||||
repo: ASSETS_REPO,
|
||||
message: this.message,
|
||||
tree: treeData.sha,
|
||||
parents: [latestCommitSha],
|
||||
});
|
||||
await octokit.git.updateRef({
|
||||
owner: 'tresabhi',
|
||||
repo: 'blitzkrieg-assets',
|
||||
repo: ASSETS_REPO,
|
||||
ref: `heads/${this.production ? 'main' : 'dev'}`,
|
||||
sha: newCommitData.sha,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user