在 Cloud Shell 中建立私人教學課程

Cloud Shell 支援建立私人教學課程,方便您為特定對象設計教學課程。

使用「在 Cloud Shell 中編寫教學課程」指南撰寫教學課程,並遵循「教學課程樣式指南」中詳述的最佳做法後,您可以在私人 Git 存放區中代管教學課程,供使用者存取。

主持私人教學課程

如要將教學課程設為私人,您需要私人 Git 存放區來託管教學課程。你可以使用任何偏好的 Git 存放區代管服務。本指南使用 Cloud Source Repositories,這是託管於 Google Cloud的私人 Git 存放區。

如要建立 Cloud Source Repositories 存放區來託管私人教學課程,請按照下列步驟操作:

  1. 啟動 Cloud Shell 終端機。 如要使用獨立的 Cloud Shell 工作階段,請前往 shell.cloud.google.com
  2. 建立私人存放區:

    gcloud source repos create REPO_NAME
    
  3. 將存放區複製到 Cloud Shell:

    gcloud source repos clone REPO_NAME
    
  4. 將教學課程檔案移至您在本機建立的存放區:

    mv PATH/TO/TUTORIAL REPO_NAME/PATH/TO/TUTORIAL
    
  5. 前往本機存放區:

    cd REPO_NAME
    
  6. 新增要提交的教學課程:

    git add .
    
  7. 將檔案提交至存放區,並附上註解說明這項動作的記錄:

    git commit -m "Add private tutorial to Cloud Source Repositories"
    
  8. 使用 git push 指令,將本機存放區的內容新增至 Cloud Source Repositories:

    git push origin master
    
  9. 在 Google Cloud 控制台中查看存放區及其內容:

    開啟 Cloud Source Repositories

如要協助使用者存取教學課程,可以使用 Cloud Shell 的「在 Cloud Shell 中開啟」功能,定義使用者存取教學課程的方式。如要瞭解如何自訂連結,請參閱「在 Cloud Shell 中開啟」指南。

如果是 Cloud Source Repositories 存放區中代管的教學課程,您需要使用存放區的網址定義 cloudshell_git_repo 參數。

以下是定義 cloudshell_git_repo 的連結範例:

https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https://source.developers.google.com/p/project_name/r/repo_name

您可以將這個連結設為按鈕,嵌入說明文件中,方便使用者輕鬆找到:

[![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https://source.developers.google.com/p/project_name/r/repo_name)

使用外掛程式自訂教學課程

您可以為使用者提供自訂工具,讓他們使用您的教學課程,進一步自訂私人教學課程體驗。

如要這麼做,您可以建立 Docker 映像檔,做為自訂 Cloud Shell 環境,並提供所有額外套件和自訂設定給使用者。