Skip to content

Commit 2608e7d

Browse files
committed
push script
1 parent 02a1729 commit 2608e7d

5 files changed

Lines changed: 34 additions & 1 deletion

File tree

.config/cspell/cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"enableGlobDot": true,
44
"useGitignore": true,
55
"gitignoreRoot": ".",
6-
"ignorePaths": ["LICENSE"],
6+
"ignorePaths": ["LICENSE", "local.env"],
77
"words": [
88
"csharpierignore",
99
"csharpierrc",

.config/git/ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ _*
44
!**/.devcontainer/**
55
!.config/
66
!**/.config/**
7+
local.env
78

89
node_modules/
910

.devcontainer/compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ services:
22
devcontainer:
33
env_file:
44
- .env
5+
- path: local.env
6+
required: false
57
build:
68
context: .
79
dockerfile: Dockerfile

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "pnpm node scripts/lint.ts",
1010
"node": "vite-node scripts/node.ts",
1111
"publish": "pnpm node scripts/publish.ts",
12+
"push": "pnpm node scripts/push.ts",
1213
"restore": "pnpm node scripts/restore.ts",
1314
"test": "pnpm node scripts/test.ts",
1415
"update": "pnpm node scripts/update.ts"

scripts/push.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import fs from "node:fs";
2+
3+
import git from "isomorphic-git";
4+
import http from "isomorphic-git/http/node";
5+
6+
import { projectRoot } from "@/scripts/project.js";
7+
8+
const currentBranch = await git.currentBranch({ fs, dir: projectRoot, fullname: false });
9+
if (!currentBranch) throw new Error("Failed to determine current branch");
10+
11+
const remote = (await git.listRemotes({ fs, dir: projectRoot })).at(0);
12+
if (remote === undefined) {
13+
throw new Error("Git remote not found");
14+
}
15+
const token = process.env.GIT_REMOTE_TOKEN;
16+
if (!token) throw new Error("GIT_REMOTE_TOKEN environment variable is not set");
17+
18+
await git.push({
19+
fs,
20+
http,
21+
dir: projectRoot,
22+
remote: remote.remote,
23+
ref: currentBranch,
24+
force: true,
25+
onAuth: () => ({
26+
username: "git",
27+
password: token,
28+
}),
29+
});

0 commit comments

Comments
 (0)