name: '๐Ÿ”ฎ Labs ยท ๐Ÿ‘๏ธ Preview (Dev)' # Builds and deploys Labs site to dev preview on: workflow_dispatch: push: branches: [dev] paths: - 'labs/**' permissions: contents: read actions: read concurrency: group: labs-dev-deploy cancel-in-progress: true jobs: build-and-deploy: name: '๐Ÿ”ฎ Build & Deploy Labs (Dev)' runs-on: ubuntu-latest steps: - name: ๐Ÿ“ฅ Checkout uses: actions/checkout@v6 - name: ๐Ÿ”ง Setup Quarto uses: quarto-dev/quarto-actions/setup@v2 - name: ๐Ÿ”จ Build Labs Site working-directory: labs run: | quarto render touch _build/.nojekyll - name: ๐Ÿ”ง Modify announcement for dev preview run: | echo "๐Ÿ”ง Modifying announcement banner for development preview..." COMMIT_SHORT="${{ github.sha }}" COMMIT_SHORT="${COMMIT_SHORT:0:8}" python3 book/tools/scripts/publish/modify_dev_announcement.py \ labs/_build \ --verbose \ --commit-hash "${{ github.sha }}" \ --commit-short "$COMMIT_SHORT" - name: ๐Ÿš€ Deploy to Dev Site via SSH env: SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} run: | echo "๐Ÿ” Starting ssh-agent..." eval "$(ssh-agent -s)" echo "$SSH_DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null # Add github.com to known hosts mkdir -p ~/.ssh ssh-keyscan github.com >> ~/.ssh/known_hosts echo "๐Ÿ”ง Configuring git..." git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" echo "๐Ÿ”„ Cloning dev preview repository (${{ vars.DEV_REPO }})..." git clone --depth=1 ${{ vars.DEV_REPO_URL }} target-repo cd target-repo echo "๐Ÿงน Cleaning ${{ vars.DEV_LABS_PATH }} directory..." rm -rf ${{ vars.DEV_LABS_PATH }} mkdir -p ${{ vars.DEV_LABS_PATH }} echo "๐Ÿšš Copying Labs site content..." cp -r "${{ github.workspace }}/labs/_build/." ${{ vars.DEV_LABS_PATH }}/ echo "๐Ÿ” Validating deployment content..." if [ ! -f "${{ vars.DEV_LABS_PATH }}/index.html" ]; then echo "โŒ CRITICAL: ${{ vars.DEV_LABS_PATH }}/index.html is missing. Aborting deployment." exit 1 fi echo "๐Ÿ”ฎ Contents of ${{ vars.DEV_LABS_PATH }}/:" ls -la ${{ vars.DEV_LABS_PATH }}/ | head -10 echo "๐Ÿ”ฎ Committing and pushing changes..." git add . git commit -m "๐Ÿ”ฎ Deploy Labs dev to /${{ vars.DEV_LABS_PATH }}/ from ${{ github.sha }}" --allow-empty || echo "๐ŸŸก Nothing to commit" git push origin main echo "โœ… Labs deployed to: https://harvard-edge.github.io/${{ vars.DEV_REPO }}/${{ vars.DEV_LABS_PATH }}/"