diff --git a/.github/workflows/clear-notebook-outputs.yml b/.github/workflows/clear-notebook-outputs.yml new file mode 100644 index 0000000..cf80a6d --- /dev/null +++ b/.github/workflows/clear-notebook-outputs.yml @@ -0,0 +1,65 @@ +# .github/workflows/clear-notebook-outputs.yml +# This workflow removes the outputs from Jupyter notebooks (.ipynb files) +# whenever changes are pushed to the repository. +# When we run a Notebook locally it generates output that we don't want to commit +name: Remove Notebook Outputs +permissions: + contents: write + +on: + push: + push: + branches: + - '**' + pull_request: + branches: + - '**' + + +jobs: + remove-notebook-outputs: + runs-on: ubuntu-latest + steps: + - name: Checkout source repo + uses: actions/checkout@v4 + + - name: Set up Git + run: | + git config --global user.name "Clear Notebook Outputs Action" + git config --global user.email "diego.freniche@mongodb.com" + + - name: Install prerequisites + run: | + sudo apt-get update -y + + sudo apt-get install python3.8 -y + + echo ✅ Install Jupyter notebook + echo ✅ ------------------------ + # Install Jupyter notebook + sudo apt-get install jupyter -y + + - name: Clear Jupyter notebook run outputs + run: | + # Get all notebook files + files=$(git ls-files '*.ipynb') + [ -z "$files" ] && exit 0 + + for f in $files; do + echo $f + # Clear outputs + execution_count in place + jupyter nbconvert \ + --ClearOutputPreprocessor.enabled=True \ + --inplace "$f" + + # Re-stage cleaned file + git add "$f" + done + + if git diff --cached --quiet; then + echo "No staged changes; skipping commit" + exit 0 + else + git commit -m "Clear notebook outputs" --no-verify + git push origin HEAD:${{ github.ref_name }} + fi \ No newline at end of file diff --git a/dotnet/01_connect_database.ipynb b/dotnet/01_connect_database.ipynb index 4bd7184..df87160 100644 --- a/dotnet/01_connect_database.ipynb +++ b/dotnet/01_connect_database.ipynb @@ -62,6 +62,7 @@ { "cell_type": "code", "execution_count": null, + "id": "2f0c35d4", "metadata": { "language_info": { "name": "polyglot-notebook" diff --git a/dotnet/101_aggregation_pipeline_arrays.ipynb b/dotnet/101_aggregation_pipeline_arrays.ipynb index 9fe63c0..fa0976d 100644 --- a/dotnet/101_aggregation_pipeline_arrays.ipynb +++ b/dotnet/101_aggregation_pipeline_arrays.ipynb @@ -122,6 +122,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8b0f11e1", "metadata": { "language_info": { "name": "polyglot-notebook" diff --git a/dotnet/102_aggregation_pipeline_unwind.ipynb b/dotnet/102_aggregation_pipeline_unwind.ipynb index 5e9a77b..9bfc9c8 100644 --- a/dotnet/102_aggregation_pipeline_unwind.ipynb +++ b/dotnet/102_aggregation_pipeline_unwind.ipynb @@ -95,6 +95,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5a9c4ac7", "metadata": { "language_info": { "name": "polyglot-notebook" diff --git a/dotnet/11_find_arrays.ipynb b/dotnet/11_find_arrays.ipynb index 5324bf7..670952a 100644 --- a/dotnet/11_find_arrays.ipynb +++ b/dotnet/11_find_arrays.ipynb @@ -82,6 +82,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8dce784e", "metadata": { "language_info": { "name": "polyglot-notebook" @@ -121,6 +122,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8dc11f3e", "metadata": { "language_info": { "name": "polyglot-notebook" @@ -161,6 +163,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f3e98e38", "metadata": { "language_info": { "name": "polyglot-notebook" @@ -204,6 +207,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a84c5e70", "metadata": { "language_info": { "name": "polyglot-notebook" diff --git a/dotnet/60_indexes.ipynb b/dotnet/60_indexes.ipynb index 3a01cb3..e53ea2c 100644 --- a/dotnet/60_indexes.ipynb +++ b/dotnet/60_indexes.ipynb @@ -164,6 +164,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8b0240c2", "metadata": { "language_info": { "name": "polyglot-notebook" @@ -200,6 +201,7 @@ { "cell_type": "code", "execution_count": null, + "id": "603d8946", "metadata": { "language_info": { "name": "polyglot-notebook" diff --git a/java/01_connect_database.ipynb b/java/01_connect_database.ipynb index bc488b5..1f23c60 100644 --- a/java/01_connect_database.ipynb +++ b/java/01_connect_database.ipynb @@ -168,7 +168,6 @@ "execution_count": null, "id": "annoying-tattoo", "metadata": { - "scrolled": true, "vscode": { "languageId": "java" }