Jupyter Notebook Runner #7
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: Jupyter Notebook Runner | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| run-notebook: | |
| runs-on: arc-runners-org-nvidia-ai-bp-1-gpu | |
| env: | |
| NOTEBOOK_PATH: ./launchable/PDFtoPodcast.ipynb | |
| PYTHON_VERSION: 3.12 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' | |
| cache-dependency-path: | | |
| requirements.txt | |
| **/*.ipynb | |
| - name: Install uv | |
| run: | | |
| # Check if uv is installed, if not, install it | |
| if ! command -v uv &> /dev/null; then | |
| echo "Installing uv..." | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| fi | |
| # Add ~/.local/bin to PATH to make `uv` accessible | |
| echo "PATH=$PATH:$HOME/.local/bin" >> $GITHUB_ENV | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install papermill jupyter | |
| # Install Docker and Docker Compose in a single step | |
| curl -fsSL https://get.docker.com -o get-docker.sh | |
| sudo sh get-docker.sh | |
| sudo apt-get update | |
| sudo apt-get install -y docker-compose-plugin docker-compose build-essential | |
| - name: Run Jupyter Notebook | |
| env: | |
| ${{ secrets }} | |
| run: | | |
| # Verify required environment variables | |
| required_vars=("ELEVENLABS_API_KEY" "NVIDIA_API_KEY") | |
| for var in "${required_vars[@]}"; do | |
| if [ -z "${!var}" ]; then | |
| echo "Error: $var is not set" | |
| exit 1 | |
| fi | |
| done | |
| OUTPUT_NOTEBOOK="result.ipynb" | |
| echo "Executing notebook: $NOTEBOOK_PATH" | |
| papermill "$NOTEBOOK_PATH" "$OUTPUT_NOTEBOOK" --log-output --log-level DEBUG | |
| - name: Convert result to html format | |
| if: always() | |
| run: | | |
| OUTPUT_NOTEBOOK="result.ipynb" | |
| jupyter nbconvert --to html "$OUTPUT_NOTEBOOK" | |
| - name: Upload the result notebook as artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: result-notebook | |
| path: "result.html" | |
| retention-days: 30 | |
| - name: Set result output | |
| id: set_result | |
| if: always() | |
| run: | | |
| echo "RESULT=$(if [ ${{ job.status }} == 'success' ]; then echo 'PASS'; else echo 'FAIL'; fi)" >> $GITHUB_OUTPUT | |
| - name: Send mail | |
| uses: dawidd6/action-send-mail@6e71c855c9a091d80a519621b9fd3e8d252ca40c | |
| if: always() | |
| with: | |
| server_address: smtp.gmail.com | |
| server_port: 587 | |
| username: ${{ secrets.SMTP_USERNAME }} | |
| password: ${{ secrets.SMTP_PASSWORD }} | |
| # Email details | |
| subject: "QA Test Workflow Result for ${{ github.repository }}" | |
| to: Github-Action-Blueprint-QA@nvidia.com | |
| from: github-workflow-notification@gmail.com | |
| html_body: | | |
| <p>Hello,</p> | |
| <p>The workflow for repository: <strong>${{ github.repository }}</strong> has completed.<br> | |
| <strong>Result:</strong> ${{ steps.set_result.outputs.RESULT }}</p> | |
| <p>You can review the details on GitHub:<br> | |
| <a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}">${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}</a></p> | |
| <p>Thanks!</p> |