Skip to content

Commit

Permalink
Test markdown changes
Browse files Browse the repository at this point in the history
  • Loading branch information
liraymond04 committed Dec 9, 2024
1 parent 06636e5 commit 7f2a7a8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/update-supabase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
id: changed-markdown-files
uses: tj-actions/changed-files@v45
with:
recover_deleted_files: true
recover_deleted_files_to_destination: 'actions/recovered'
separator: ","
files: |
**/*.md
Expand Down
8 changes: 0 additions & 8 deletions posts/new.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: webnovel
title: SBMP Part 4
title: Stand by me Pleiades Part 4
repo_url: liraymond04/re0-translations
file_path: posts/side_stories/Stand by me Pleiades Part 4/Stand by me Pleiades Part 4.md
supabase_page_format: true
Expand All @@ -10,7 +10,7 @@ supabase_page_format: true
<img src="./media/image2.png"
style="margin:auto;height:auto;width:6.5in" />

SBMP Part 4
Stand by me Pleiades Part 4

</div>

Expand Down
18 changes: 14 additions & 4 deletions scripts/process_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def update_post_field_in_db(metadata, field):
.eq("file_path", metadata["file_path"])
.execute()
)
logger.info(f"Successfully updated {field} in post for {file}:\n{metadata[field]}")
logger.info(f"Successfully updated {field} in post for {file}")
except Exception as e:
logger.error(f"Error updating {field} in post for {file}: {e}")
sys.exit(1)
Expand Down Expand Up @@ -119,7 +119,14 @@ def create_new_post(file, metadata):

def delete_post(file, metadata):
try:
_ = supabase.table("posts").delete().eq("id", metadata["id"]).execute()
_ = (
supabase
.table("posts")
.delete()
.eq("repo_url", metadata["repo_url"])
.eq("file_path", metadata["file_path"])
.execute()
)
except Exception as e:
logger.error(f"Error deleting post for {file}: {e}")
sys.exit(1)
Expand All @@ -146,8 +153,11 @@ def check_if_differences_exist(file, metadata):
logger.error(f"Error checking differences for {file}: {e}")
sys.exit(1)

def read_markdown_metadata(file_path):
def read_markdown_metadata(file_path, deleted=False):
try:
if deleted:
file_path = os.path.join("actions/recovered", file_path)

with open(file_path, 'r') as f:
content = f.read()

Expand Down Expand Up @@ -202,7 +212,7 @@ def main():
for file in deleted_files:
if file.endswith('.md'):
logger.info(f"Processing {file}")
metadata = read_markdown_metadata(file)
metadata = read_markdown_metadata(file, deleted=True)
# print("Markdown files were deleted.")
# print(metadata)
delete_post(file, metadata)
Expand Down

0 comments on commit 7f2a7a8

Please sign in to comment.