diff --git a/.github/workflows/commit-parser.yml b/.github/workflows/commit-parser.yml new file mode 100644 index 000000000000..20d8ef953c9c --- /dev/null +++ b/.github/workflows/commit-parser.yml @@ -0,0 +1,50 @@ +name: Generate HTML from Recent Commits + +on: + workflow_dispatch: + schedule: + - cron: '0 12 1 * *' # Run 1st day of the month every 30 days + +jobs: + generate_html: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Checkout Wiki + uses: actions/checkout@v4 + with: + repository: classicrocker883/Marlin.wiki + path: wiki + token: ${{ secrets.GITHUB_TOKEN }} + sparse-checkout: | + "What's-New-in-this-Release.md" + sparse-checkout-cone-mode: false + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: + pip install requests && pip install emoji + + - name: Generate Commits and merge with HTML + run: | + python buildroot/share/scripts/generate_html.py + while [ ! -f buildroot/share/scripts/output_HTML_commits.txt ]; do + sleep 1 + done + python buildroot/share/scripts/commit_to_wiki.py + + - name: Commit and Push Changes + run: | + git config user.name "Andrew" + git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" + git remote add wiki https://github.com/classicrocker883/Marlin.wiki.git + git add "wiki/What's-New-in-this-Release.md" + git commit -m "⛙ Merge new commits into wiki" + git push wiki master diff --git a/.github/workflows/commit_parser.yml b/.github/workflows/commit_parser.yml deleted file mode 100644 index 843939312055..000000000000 --- a/.github/workflows/commit_parser.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Generate HTML from Recent Commits - -on: - workflow_dispatch: - schedule: - - cron: '0 0 1 * *' # Run weekly on Sundays - -jobs: - generate_html: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: Install dependencies - run: - pip install requests - pip install emoji - - - name: Generate HTML from Commits - run: | - python generate_html.py > output_HTML_commits.txt - - - name: Commit and Push Changes - run: | - git config user.name "Andrew" - git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" - git add output_HTML_commits.txt - git commit -m "Generate HTML from recent commits" - git push diff --git a/buildroot/share/scripts/commit_to_wiki.py b/buildroot/share/scripts/commit_to_wiki.py new file mode 100644 index 000000000000..1bcd5e97927b --- /dev/null +++ b/buildroot/share/scripts/commit_to_wiki.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import os + +# Define the path to output_HTML_commits.txt within the workspace directory +output_commits_path = os.path.join(os.getenv('GITHUB_WORKSPACE'), 'buildroot', 'share', 'scripts', 'output_HTML_commits.txt') + +# Check if output_HTML_commits.txt exists +if not os.path.exists(output_commits_path): + print(f"Error: output_HTML_commits.txt not found at {output_commits_path}") + print("Falling back to default path...") + output_commits_path = 'buildroot/share/scripts/output_HTML_commits.txt' + +if not os.path.exists(output_commits_path): + print(f"Error: output_HTML_commits.txt not found at buildroot/share/scripts") + exit(1) + +# Read the contents of output_HTML_commits.txt +with open(output_commits_path, 'r') as file1: + file1_content = file1.readlines() + +# Define the path to What's-New-in-this-Release.md within the workspace directory +release_notes_path = os.path.join(os.getenv('GITHUB_WORKSPACE'), "wiki", "What's-New-in-this-Release.md") + +# Check if What's-New-in-this-Release.md exists +if not os.path.exists(release_notes_path): + print(f"Error: What's-New-in-this-Release.md not found at {release_notes_path}") + print("Falling back to default path...") + release_notes_path = "wiki/What's-New-in-this-Release.md" + +if not os.path.exists(release_notes_path): + print(f"Error: What's-New-in-this-Release.md not found at wiki") + exit(1) +# with open("https://raw.githubusercontent.com/wiki/classicrocker883/MRiscoCProUI/What's-New-in-this-Release.md", 'r') as file2: +# file2_content = file2.readlines() + +# Read the content of What's-New-in-this-Release.md +with open(release_notes_path, 'r') as file2: + file2_content = file2.readlines() + +# Find the position of