Skip to content

Commit 25bc0de

Browse files
committed
Upload config files using the new format
1 parent 046dbab commit 25bc0de

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/lesson.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,31 @@ export async function handleLesson(
120120
// If there's still no lesson, throw an error.
121121
if (!lessonID) throw new Error("Could not create or find a lesson!");
122122

123-
// Now, we need to upload the video, if it exists.
123+
// Now, we need to upload the config file, if it exists.
124+
if (fs.existsSync(Path.join(dir, "config.json"))) {
125+
const configForm = new FormData();
126+
configForm.append(
127+
"config",
128+
fs.createReadStream(Path.join(dir, "config.json")),
129+
);
130+
131+
await axios.put(
132+
new URL(
133+
"/internal/api/config/upload/" + lessonID,
134+
core.getInput("domain"),
135+
).toString(),
136+
configForm,
137+
{
138+
headers: {
139+
...configForm.getHeaders(),
140+
authorization: core.getInput("key"),
141+
},
142+
},
143+
);
144+
await delay(state);
145+
}
146+
147+
// Next, we need to upload the video, if it exists.
124148
if (fs.existsSync(Path.join(dir, "video.cv"))) {
125149
const videoForm = new FormData();
126150
videoForm.append(
@@ -171,7 +195,7 @@ export async function handleLesson(
171195
for (const entry of walkEntries) {
172196
if (!entry[1].isFile()) continue;
173197

174-
if (entry[2] === "manifest.json" || entry[2] === "video.cv") continue;
198+
if (["manifest.json", "video.cv", "config.json"].includes(entry[2])) continue;
175199

176200
files[entry[2]] = await fs.promises.readFile(entry[0], "utf-8");
177201
}

0 commit comments

Comments
 (0)