Skip to content

Commit

Permalink
chore: v0.0.11
Browse files Browse the repository at this point in the history
- svg 확장자 추가
- main 브랜치를 받아오는게 아닌 targetBranch의 tree를 받도록 수정
  • Loading branch information
junghyeonsu committed May 24, 2023
1 parent 97ca6c9 commit fa743ba
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
17 changes: 7 additions & 10 deletions packages/figma-svg-extract-action/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11296,8 +11296,7 @@ try {
repo: repo,
contents: svgs,
message: "Update svg",
// TODO: path를 어떻게 처리할지 고민해보자.
// path: "svg",
path: "svg",
targetBranch: currentBranch,
});
core.info("End svg extracter");
Expand Down Expand Up @@ -11359,19 +11358,17 @@ const octokitClient = (githubToken) => {
});
return octokit;
};
const pushToGithub = ({ contents, githubToken, message, owner,
// path,
repo, targetBranch, }) => __awaiter(void 0, void 0, void 0, function* () {
const pushToGithub = ({ contents, githubToken, message, owner, path, repo, targetBranch, }) => __awaiter(void 0, void 0, void 0, function* () {
const octokit = octokitClient(githubToken);
const { data: baseBranch } = yield octokit.request("GET /repos/{owner}/{repo}/branches/{branch}", {
const { data: targetBranchTree } = yield octokit.request("GET /repos/{owner}/{repo}/branches/{branch}", {
owner,
repo,
branch: "main",
branch: targetBranch,
});
const { data: baseTree } = yield octokit.request("GET /repos/{owner}/{repo}/git/trees/{tree_sha}", {
owner,
repo,
tree_sha: baseBranch.commit.sha,
tree_sha: targetBranchTree.commit.sha,
});
const blobs = yield Promise.all(contents.map((content) => octokit
.request("POST /repos/{owner}/{repo}/git/blobs", {
Expand All @@ -11386,7 +11383,7 @@ repo, targetBranch, }) => __awaiter(void 0, void 0, void 0, function* () {
}))));
const treeBlobs = blobs.map((blob) => {
return {
path: blob.name,
path: path ? `${path}/${blob.name}.svg` : `${blob.name}.svg`,
mode: "100644",
type: "blob",
sha: blob.data.sha,
Expand All @@ -11403,7 +11400,7 @@ repo, targetBranch, }) => __awaiter(void 0, void 0, void 0, function* () {
repo,
message,
tree: tree.data.sha,
parents: [baseBranch.commit.sha],
parents: [targetBranchTree.commit.sha],
});
const currentRef = yield octokit.request("GET /repos/{owner}/{repo}/git/ref/{ref}", {
owner,
Expand Down
3 changes: 2 additions & 1 deletion packages/figma-svg-extract-action/dist/octokit.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
declare const pushToGithub: ({ contents, githubToken, message, owner, repo, targetBranch, }: {
declare const pushToGithub: ({ contents, githubToken, message, owner, path, repo, targetBranch, }: {
githubToken: string;
owner: string;
repo: string;
path: string;
contents: {
name: string;
svg: string;
Expand Down
14 changes: 6 additions & 8 deletions packages/figma-svg-extract-action/dist/octokit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,17 @@ const octokitClient = (githubToken) => {
});
return octokit;
};
const pushToGithub = ({ contents, githubToken, message, owner,
// path,
repo, targetBranch, }) => __awaiter(void 0, void 0, void 0, function* () {
const pushToGithub = ({ contents, githubToken, message, owner, path, repo, targetBranch, }) => __awaiter(void 0, void 0, void 0, function* () {
const octokit = octokitClient(githubToken);
const { data: baseBranch } = yield octokit.request("GET /repos/{owner}/{repo}/branches/{branch}", {
const { data: targetBranchTree } = yield octokit.request("GET /repos/{owner}/{repo}/branches/{branch}", {
owner,
repo,
branch: "main",
branch: targetBranch,
});
const { data: baseTree } = yield octokit.request("GET /repos/{owner}/{repo}/git/trees/{tree_sha}", {
owner,
repo,
tree_sha: baseBranch.commit.sha,
tree_sha: targetBranchTree.commit.sha,
});
const blobs = yield Promise.all(contents.map((content) => octokit
.request("POST /repos/{owner}/{repo}/git/blobs", {
Expand All @@ -68,7 +66,7 @@ repo, targetBranch, }) => __awaiter(void 0, void 0, void 0, function* () {
}))));
const treeBlobs = blobs.map((blob) => {
return {
path: blob.name,
path: path ? `${path}/${blob.name}.svg` : `${blob.name}.svg`,
mode: "100644",
type: "blob",
sha: blob.data.sha,
Expand All @@ -85,7 +83,7 @@ repo, targetBranch, }) => __awaiter(void 0, void 0, void 0, function* () {
repo,
message,
tree: tree.data.sha,
parents: [baseBranch.commit.sha],
parents: [targetBranchTree.commit.sha],
});
const currentRef = yield octokit.request("GET /repos/{owner}/{repo}/git/ref/{ref}", {
owner,
Expand Down
2 changes: 1 addition & 1 deletion packages/figma-svg-extract-action/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "figma-svg-extract-action",
"version": "0.0.10",
"version": "0.0.11",
"main": "dist/index.js",
"scripts": {
"build": "tsc && ncc build"
Expand Down
3 changes: 1 addition & 2 deletions packages/figma-svg-extract-action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ try {
repo: repo!,
contents: svgs,
message: "Update svg",
// TODO: path를 어떻게 처리할지 고민해보자.
// path: "svg",
path: "svg",
targetBranch: currentBranch!,
});

Expand Down
14 changes: 7 additions & 7 deletions packages/figma-svg-extract-action/src/octokit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ const pushToGithub = async ({
githubToken,
message,
owner,
// path,
path,
repo,
targetBranch,
}: {
githubToken: string;
owner: string;
repo: string;
// path: string;
path: string;
contents: { name: string; svg: string }[];
message: string;
targetBranch: string;
}) => {
const octokit = octokitClient(githubToken);

const { data: baseBranch } = await octokit.request(
const { data: targetBranchTree } = await octokit.request(
"GET /repos/{owner}/{repo}/branches/{branch}",
{
owner,
repo,
branch: "main",
branch: targetBranch,
},
);

Expand All @@ -42,7 +42,7 @@ const pushToGithub = async ({
{
owner,
repo,
tree_sha: baseBranch.commit.sha,
tree_sha: targetBranchTree.commit.sha,
},
);

Expand Down Expand Up @@ -72,7 +72,7 @@ const pushToGithub = async ({

const treeBlobs = blobs.map((blob) => {
return {
path: blob.name,
path: path ? `${path}/${blob.name}.svg` : `${blob.name}.svg`,
mode: "100644",
type: "blob",
sha: blob.data.sha,
Expand All @@ -93,7 +93,7 @@ const pushToGithub = async ({
repo,
message,
tree: tree.data.sha,
parents: [baseBranch.commit.sha],
parents: [targetBranchTree.commit.sha],
},
);

Expand Down

0 comments on commit fa743ba

Please sign in to comment.