Rosetta Code Auto-Scraper #13
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: Rosetta Code Auto-Scraper | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 0' | |
| workflow_dispatch: {} | |
| jobs: | |
| scrape-and-publish: | |
| runs-on: ubuntu-latest | |
| env: | |
| PYTHONDONTWRITEBYTECODE: 1 | |
| steps: | |
| - name: Checkout Zen-C Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| path: 'zen-c' | |
| token: ${{ secrets.WEBSITE_REPO_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Checkout Docs Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: 'zenc-lang/docs' | |
| token: ${{ secrets.WEBSITE_REPO_TOKEN }} | |
| path: 'docs' | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Setup Awesome-Zen-C repository | |
| run: | | |
| cd zen-c | |
| git clone https://x-access-token:${{ secrets.WEBSITE_REPO_TOKEN }}@github.com/zenc-lang/awesome-zenc.git examples | |
| - name: Run Rosetta Code Scraper | |
| run: | | |
| cd zen-c | |
| python .github/scripts/scrape_rosetta.py | |
| - name: Commit .zc files to Awesome-Zen-C Repo | |
| run: | | |
| cd zen-c/examples | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git checkout main || git checkout -b main | |
| git add examples/rosetta/ | |
| git diff --quiet && git diff --staged --quiet || (git commit -m "chore: auto-sync new Rosetta Code examples" && git push origin HEAD:main) | |
| - name: Sync Markdown to Docs Repo | |
| run: | | |
| mkdir -p docs/rosetta/ | |
| rsync -avz --delete --exclude='_index.md' zen-c/website_out/ docs/rosetta/ | |
| cd docs | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add rosetta/ | |
| git diff --quiet && git diff --staged --quiet || (git commit -m "docs: auto-sync Rosetta Code examples from zenc repo" && git push) |