Skip to content

Commit dc7c3a5

Browse files
committed
Issue 15
1 parent 2aaa157 commit dc7c3a5

1 file changed

Lines changed: 96 additions & 96 deletions

File tree

src/libs/makeWorkflow.ts

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,104 +4,104 @@ import fs from "fs";
44
import yaml from "yaml";
55

66
export async function makeWorkflow() {
7-
const config = vscode.workspace.getConfiguration("BOJ");
8-
const author = config.get<string>("author", "");
7+
const config = vscode.workspace.getConfiguration("BOJ");
8+
const author = config.get<string>("author", "");
99

10-
try {
11-
// 폴더명 생성
12-
const folderName = ".github";
13-
const folderPath = path.join(
14-
vscode.workspace.workspaceFolders![0].uri.fsPath,
15-
folderName
16-
);
17-
fs.mkdirSync(folderPath, { recursive: true });
10+
try {
11+
// 폴더명 생성
12+
const folderName = ".github";
13+
const folderPath = path.join(
14+
vscode.workspace.workspaceFolders![0].uri.fsPath,
15+
folderName
16+
);
17+
fs.mkdirSync(folderPath, { recursive: true });
1818

19-
const subFolderName = "workflows";
20-
const subFolderPath = path.join(folderPath, subFolderName);
21-
fs.mkdirSync(subFolderPath, { recursive: true });
19+
const subFolderName = "workflows";
20+
const subFolderPath = path.join(folderPath, subFolderName);
21+
fs.mkdirSync(subFolderPath, { recursive: true });
2222

23-
const content = {
24-
name: "Update Markdown Performance",
25-
on: {
26-
push: {
27-
paths: ["**.md"],
28-
},
29-
},
30-
jobs: {
31-
update: {
32-
"runs-on": "ubuntu-latest",
33-
steps: [
34-
{
35-
name: "Checkout Repository",
36-
uses: "actions/checkout@v2",
37-
with: {
38-
"fetch-depth": 0,
39-
token: "${{ secrets.GH_TOKEN }}",
40-
},
41-
},
42-
{
43-
name: "Get List of Not Filled Markdown Files",
44-
id: "getfile",
45-
run: [
46-
'echo "" > not_filled_files.txt',
47-
"while IFS= read -r -d $'\\0' file; do",
48-
'\tif ! grep -q "### 성능 요약" "$file"; then',
49-
'\t\techo "$file" >> not_filled_files.txt',
50-
"\tfi",
51-
'done < <(find . -name "*.md" -print0)',
52-
].join("\n"),
53-
},
54-
{
55-
name: "Update Performance in Markdown",
56-
uses: "dltkdgns00/BOJ-action@main",
57-
with: {
58-
path: "not_filled_files.txt",
59-
user_id: author,
60-
},
61-
},
62-
{
63-
name: "remove not_filled_files.txt",
64-
run: ["rm not_filled_files.txt"].join("\n"),
65-
},
66-
{
67-
name: "Commit and push changes",
68-
run: [
69-
'git config --local user.email "github-actions[bot]@users.noreply.github.com"',
70-
'git config --local user.name "github-actions[bot]"',
71-
"git add .",
72-
"git status",
73-
'if [[ -n "$(git status --porcelain)" ]]; then',
74-
'\tgit commit -m "Update performance details"',
75-
"\tgit push",
76-
"else",
77-
'\techo "No changes to commit."',
78-
"fi",
79-
].join("\n"),
80-
},
81-
],
82-
},
83-
},
84-
};
23+
const content = {
24+
name: "Update Markdown Performance",
25+
on: {
26+
push: {
27+
paths: ["**.md"],
28+
},
29+
},
30+
jobs: {
31+
update: {
32+
"runs-on": "ubuntu-latest",
33+
steps: [
34+
{
35+
name: "Checkout Repository",
36+
uses: "actions/checkout@v2",
37+
with: {
38+
"fetch-depth": 0,
39+
token: "${{ secrets.GH_TOKEN }}",
40+
},
41+
},
42+
{
43+
name: "Get List of Not Filled Markdown Files",
44+
id: "getfile",
45+
run: [
46+
'echo "" > not_filled_files.txt',
47+
"while IFS= read -r -d $'\\0' file; do",
48+
'\tif ! grep -q "### 성능 요약" "$file"; then',
49+
'\t\techo "$file" >> not_filled_files.txt',
50+
"\tfi",
51+
'done < <(find . -name "*.md" -print0)',
52+
].join("\n"),
53+
},
54+
{
55+
name: "Update Performance in Markdown",
56+
uses: "dltkdgns00/BOJ-action@main",
57+
with: {
58+
path: "not_filled_files.txt",
59+
user_id: author,
60+
},
61+
},
62+
{
63+
name: "remove not_filled_files.txt",
64+
run: ["rm not_filled_files.txt"].join("\n"),
65+
},
66+
{
67+
name: "Commit and push changes",
68+
run: [
69+
'git config --local user.email "github-actions[bot]@users.noreply.github.com"',
70+
'git config --local user.name "github-actions[bot]"',
71+
"git add .",
72+
"git status",
73+
'if [[ -n "$(git status --porcelain)" ]]; then',
74+
'\tgit commit -m "Update performance details"',
75+
"\tgit push",
76+
"else",
77+
'\techo "No changes to commit."',
78+
"fi",
79+
].join("\n"),
80+
},
81+
],
82+
},
83+
},
84+
};
8585

86-
console.log(content);
87-
const yamlStr = yaml.stringify(content);
88-
const yamlFilePath = path.join(subFolderPath, "workflow.yml");
89-
fs.writeFile(yamlFilePath, yamlStr, (err) => {
90-
if (err) {
91-
throw err;
92-
}
93-
});
94-
console.log("YAML 파일이 성공적으로 생성되었습니다.");
95-
} catch (error) {
96-
if (error instanceof Error && (error as any).code === "EEXIST") {
97-
console.log("workflow.yml 파일이 이미 존재하므로 생성하지 않습니다.");
98-
return;
99-
} else {
100-
vscode.window.showErrorMessage(
101-
"워크플로우 파일 생성에 실패했습니다. 권한을 확인하거나 다시 시도해주세요."
102-
);
103-
console.log(error);
104-
return;
105-
}
106-
}
86+
console.log(content);
87+
const yamlStr = yaml.stringify(content);
88+
const yamlFilePath = path.join(subFolderPath, "workflow.yml");
89+
fs.writeFile(yamlFilePath, yamlStr, (err) => {
90+
if (err) {
91+
throw err;
92+
}
93+
});
94+
console.log("YAML 파일이 성공적으로 생성되었습니다.");
95+
} catch (error) {
96+
if (error instanceof Error && (error as any).code === "EEXIST") {
97+
console.log("workflow.yml 파일이 이미 존재하므로 생성하지 않습니다.");
98+
return;
99+
} else {
100+
vscode.window.showErrorMessage(
101+
"워크플로우 파일 생성에 실패했습니다. 권한을 확인하거나 다시 시도해주세요."
102+
);
103+
console.log(error);
104+
return;
105+
}
106+
}
107107
}

0 commit comments

Comments
 (0)