name: Build and Deploy BSc Code Index on: push: branches: - main paths-ignore: - 'CHANGELOG.md' workflow_dispatch: permissions: contents: write pages: write id-token: write concurrency: group: pages cancel-in-progress: false jobs: sync-hf: runs-on: ubuntu-latest if: github.actor != 'github-actions[bot]' steps: - name: Checkout GitHub Repo uses: actions/checkout@v4 with: fetch-depth: 1 - name: Safe Sync to Hugging Face env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git clone https://notamitgamer:${HF_TOKEN}@huggingface.co/datasets/notamitgamer/usercontent /tmp/hf_repo rsync -av --delete \ --exclude='.git' \ --exclude='MinGW64' \ --exclude='*.exe' \ --exclude='site_files' \ $GITHUB_WORKSPACE/ /tmp/hf_repo/ cd /tmp/hf_repo git lfs install git lfs track "*.pdf" git lfs track "*.docx" git add .gitattributes git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . git commit -m "Safe auto-sync: updating GitHub files while protecting dynamic folders" || echo "No changes to commit" git push origin main build: runs-on: ubuntu-latest if: github.actor != 'github-actions[bot]' steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v5 with: python-version: '3.13' - name: Generate markdown files run: | python list.py python md.py - name: Generate changelog env: BUILD_SHA: ${{ github.sha }} BUILD_ACTOR: ${{ github.actor }} BUILD_REF: ${{ github.ref_name }} BUILD_TIMESTAMP: ${{ github.event.head_commit.timestamp }} run: | git log --pretty=format:"%H|%s|%an|%aI" -20 > git_log.txt python changelog.py - name: Commit generated changelog to repo run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add CHANGELOG.md if ! git diff --cached --quiet; then git commit -m "chore: update changelog [skip ci]" git push else echo "No changes" fi - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 22 cache: npm - name: Install dependencies run: npm ci - name: Build VitePress run: npm run docs:build env: VITE_DEPLOY_ID: ${{ github.sha }} - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: docs/.vitepress/dist deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest if: github.actor != 'github-actions[bot]' needs: build steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4