Action That Copies and Deletes the First Line of Text in a Draft

I am a similar boat when it comes to being new to Drafts and new to Javascript – though I find it readable since I work (as a researcher not a programmer!) with Python.

What I want is a way to take a Drafts text, grab the first line, use that as the name of the file, and then delete that line from the saved text. E.g.:

2022-12-30-new-file
---
title: A New Post in a GitHub Pages Blog
layout: post
---

Lorem impsum

Would not have 2022-12-30-new-file at the beginning of the file.

I have searched this forum and I have tried searching the Drafts Directory, but it says every one of my searches is too specific, no matter when I get them down to one word.