Upload document.html for conversion #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Convert Files to Markdown | |
| on: | |
| push: | |
| paths: | |
| - 'uploads/**' | |
| workflow_dispatch: | |
| jobs: | |
| convert: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install markitdown | |
| - name: Convert files | |
| run: | | |
| mkdir -p docs/converted | |
| for file in uploads/*; do | |
| if [ -f "$file" ]; then | |
| filename=$(basename "$file") | |
| output_file="docs/converted/${filename%.*}.md" | |
| echo "Converting $filename to Markdown..." | |
| markitdown "$file" -o "$output_file" || echo "Failed to convert $filename" | |
| fi | |
| done | |
| - name: Commit converted files | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add docs/converted/ | |
| git commit -m "Convert files to Markdown" || echo "No changes to commit" | |
| git push |