diff --git a/.github/workflows/convert-to-qmd.yml b/.github/workflows/convert-to-qmd.yml index 842bd66..972927c 100644 --- a/.github/workflows/convert-to-qmd.yml +++ b/.github/workflows/convert-to-qmd.yml @@ -11,6 +11,7 @@ jobs: permissions: contents: write # Ensure the job has write permissions + issues: write # Required for API calls to create and delete deploy keys steps: - name: Checkout the Linear_Algebra_with_Python repository @@ -29,11 +30,32 @@ jobs: quarto convert "$notebook" -o "converted_chapters/$(basename "$notebook" .ipynb).qmd" done + - name: Generate SSH Key + run: | + ssh-keygen -t rsa -b 4096 -C "actions@github.com" -f /tmp/github_actions -N "" + echo "::set-output name=ssh-public-key::$(cat /tmp/github_actions.pub)" + + - name: Add SSH Key to the SSH Agent + run: | + eval "$(ssh-agent -s)" + ssh-add /tmp/github_actions + + - name: Add Deploy Key to GitHub + id: add_deploy_key + run: | + curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/weijie-chen/weijie-chen.github.io/keys \ + -d "{\"title\":\"GitHub Actions Key\",\"key\":\"$(cat /tmp/github_actions.pub)\",\"read_only\":false}" \ + -o deploy_key.json + echo "::set-output name=deploy-key-id::$(jq -r .id deploy_key.json)" + - name: Checkout the weijie-chen.github.io repository uses: actions/checkout@v4.1.7 with: repository: weijie-chen/weijie-chen.github.io path: book_repo + ssh-key: /tmp/github_actions # Use the dynamically generated SSH key - name: Copy Converted QMD Files to Book Repository run: | @@ -50,11 +72,6 @@ jobs: sed -i '/
/,/<\/section>/{//!d}' book_repo/linear-algebra-with-python-book/index.html sed -i "/
/a $toc" book_repo/linear-algebra-with-python-book/index.html - - name: Set up SSH Agent - uses: webfactory/ssh-agent@v0.5.3 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Commit and Push Changes via SSH run: | cd book_repo @@ -64,3 +81,9 @@ jobs: git add linear-algebra-with-python-book/index.html git commit -m "Updated chapters and Table of Contents" git push git@github.com:weijie-chen/weijie-chen.github.io.git main + + - name: Clean Up - Remove Deploy Key from GitHub + run: | + DEPLOY_KEY_ID=$(jq -r .id deploy_key.json) + curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/weijie-chen/weijie-chen.github.io/keys/$DEPLOY_KEY_ID diff --git a/notebooks/Chapter 2 - Basic Matrix Algebra.ipynb b/notebooks/Chapter 2 - Basic Matrix Algebra.ipynb index bf202cd..1820ebd 100644 --- a/notebooks/Chapter 2 - Basic Matrix Algebra.ipynb +++ b/notebooks/Chapter 2 - Basic Matrix Algebra.ipynb @@ -28,7 +28,7 @@ "outputs": [], "source": [ "from IPython.core.interactiveshell import InteractiveShell\n", - "InteractiveShell.ast_node_interactivity = \"all\" # display multiple lines" + "InteractiveShell.ast_node_interactivity = \"all\" # display multiple lines." ] }, {