

Amazon CodeCatalyst 不再向新客戶開放。現有客戶可以繼續正常使用該服務。如需詳細資訊，請參閱[如何從 CodeCatalyst 遷移](migration.md)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 與 GitHub 動作整合
<a name="integrations-github-actions"></a>

*GitHub 動作*非常類似 [CodeCatalyst 動作](workflows-actions.md#workflows-actions-types-cc)，但其開發用於 GitHub 工作流程。如需 GitHub 動作的詳細資訊，請參閱 [GitHub 動作](https://docs.github.com/en/actions)文件。

您可以在 CodeCatalyst 工作流程中使用 GitHub 動作與原生 CodeCatalyst 動作。

有兩種方式可將 GitHub 動作新增至 CodeCatalyst 工作流程：
+ 您可以從 CodeCatalyst 主控台的策劃清單中選取 GitHub 動作。有數個熱門的 GitHub 動作可供使用。如需詳細資訊，請參閱[新增精選的 GitHub 動作](integrations-github-action-add-curated.md)。
+ 如果您想要使用的 GitHub 動作無法在 CodeCatalyst 主控台中使用，您可以使用 **GitHub 動作**新增它。

  ***GitHub Actions*** 動作是 *CodeCatalyst 動作*，可包裝 GitHub 動作，使其與 CodeCatalyst 工作流程相容。

  以下是包裝 [Super-Linter](https://github.com/marketplace/actions/super-linter) **GitHub 動作**的 GitHub 動作動作範例：

  ```
  Actions:
    GitHubAction:
      Identifier: aws/github-actions-runner@v1
      Configuration:
        Steps:
          - name: Lint Code Base
            uses: github/super-linter@v4
            env:
              VALIDATE_ALL_CODEBASE: "true"
              DEFAULT_BRANCH: main
  ```

  在先前的程式碼中，CodeCatalyst **GitHub Actions** 動作 （由 識別`aws/github-actions-runner@v1`) 會包裝 Super-Linter 動作 （由 識別`github/super-linter@v4`)，使其可在 CodeCatalyst 工作流程中運作。

  如需詳細資訊，請參閱[新增「GitHub 動作」動作](integrations-github-action-add.md)。

所有 GitHub 動作 - 無論是否經過策劃，都必須包裝在 **GitHub 動作**動作 (`aws/github-actions-runner@v1`) 內，如上一個範例所示。動作需要包裝函式才能正常運作。

**Topics**
+ [GitHub 動作與 CodeCatalyst 動作有何不同？](#integrations-github-actions-how-different)
+ [GitHub 動作是否可以與工作流程中的其他 CodeCatalyst 動作互動？](#integrations-github-actions-interactions.title)
+ [我可以使用哪些 GitHub 動作？](#integrations-github-actions-supported)
+ [CodeCatalyst 中 GitHub 動作的限制](#integrations-github-actions-limitations)
+ [如何新增 GitHub 動作 （高階步驟）？](#integrations-github-actions-how-to)
+ [GitHub 動作是否在 GitHub 中執行？](#integrations-github-actions-where-it-runs)
+ [也可以使用 GitHub 工作流程嗎？](#integrations-github-actions-workflows-support.title)
+ [「GitHub 動作」動作所使用的執行期映像](#integrations-github-actions-runtime)
+ [教學課程：使用 GitHub 動作的 Lint 程式碼](integrations-github-action-tutorial.md)
+ [新增「GitHub 動作」動作](integrations-github-action-add.md)
+ [新增精選的 GitHub 動作](integrations-github-action-add-curated.md)
+ [匯出 GitHub 輸出參數](integrations-github-action-export.md)
+ [參考 GitHub 輸出參數](integrations-github-action-referencing.md)
+ [「GitHub 動作」動作 YAML](github-action-ref.md)

## GitHub 動作與 CodeCatalyst 動作有何不同？
<a name="integrations-github-actions-how-different"></a>

在 CodeCatalyst 工作流程中使用的 GitHub 動作與 CodeCatalyst 動作的存取和整合層級不同 AWS 和 CodeCatalyst 功能 （例如[環境](deploy-environments.md)和[問題](issues.md))。

## GitHub 動作是否可以與工作流程中的其他 CodeCatalyst 動作互動？
<a name="integrations-github-actions-interactions.title"></a>

是。例如，GitHub Actions 可以使用其他 CodeCatalyst 動作產生的變數做為輸入，也可以與 CodeCatalyst 動作共用輸出參數和成品。如需詳細資訊，請參閱[匯出 GitHub 輸出參數](integrations-github-action-export.md)及[參考 GitHub 輸出參數](integrations-github-action-referencing.md)。

## 我可以使用哪些 GitHub 動作？
<a name="integrations-github-actions-supported"></a>

您可以使用 CodeCatalyst 主控台提供的任何 GitHub 動作，以及 GitHub [Marketplace 中提供的任何 GitHub ](https://github.com/marketplace/actions)動作。如果您決定從 Marketplace 使用 GitHub 動作，請記住下列[限制](#integrations-github-actions-limitations)。

## CodeCatalyst 中 GitHub 動作的限制
<a name="integrations-github-actions-limitations"></a>
+ GitHub 動作無法與 CodeCatalyst [Lambda 運算類型](workflows-working-compute.md#compute.types)搭配使用。
+ GitHub 動作會在 [2022 年 11 月](build-images.md#build.previous-image)執行時間環境 Docker 映像上執行，其中包含較舊的工具。如需映像和工具的詳細資訊，請參閱 [指定執行時間環境映像](build-images.md)。
+ 內部依賴[`github`內容](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context)或參考 GitHub 特定資源的 GitHub 動作無法在 CodeCatalyst 中運作。例如，下列動作無法在 CodeCatalyst 中運作：
  + 嘗試新增、變更或更新 GitHub 資源的動作。範例包括更新提取請求的動作，或在 GitHub 中建立問題。
  + 幾乎所有列於 https：//[https://github.com/actions](https://github.com/actions) 的動作。
+ 屬於 Docker 容器動作的 GitHub 動作將可運作，但必須由預設的 Docker 使用者 （根） 執行。 [https://docs.github.com/en/actions/creating-actions/about-custom-actions#docker-container-actions](https://docs.github.com/en/actions/creating-actions/about-custom-actions#docker-container-actions)請勿以使用者 1001 身分執行動作。（撰寫時，使用者 1001 可在 GitHub 中運作，但無法在 CodeCatalyst.) 如需詳細資訊，請參閱 [Dockerfile 支援 GitHub 動作](https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions)中的 [USER](https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user) 主題。

如需透過 CodeCatalyst 主控台提供的 GitHub 動作清單，請參閱 [新增精選的 GitHub 動作](integrations-github-action-add-curated.md)。

## 如何新增 GitHub 動作 （高階步驟）？
<a name="integrations-github-actions-how-to"></a>

將 GitHub 動作新增至 CodeCatalyst 工作流程的高階步驟如下所示：

1. 在 CodeCatalyst 專案中，您可以**建立工作流程**。工作流程是您定義如何建置、測試和部署應用程式的地方。如需詳細資訊，請參閱[工作流程入門](workflows-getting-started.md)。

1. 在工作流程中，您可以**新增策劃的 GitHub 動作**，或**新增 GitHub 動作**動作。

1. 您執行下列其中一項操作：
   + 如果您選擇新增策劃的動作，請進行設定。如需詳細資訊，請參閱[新增精選的 GitHub 動作](integrations-github-action-add-curated.md)。
   + 如果您選擇新增非策劃的動作，請在 **GitHub 動作**動作中**貼上 GitHub 動作的 YAML 程式碼**。您可以在 GitHub [GitHub Marketplace](https://github.com/marketplace/actions) 中所選 GitHub 動作的詳細資訊頁面上找到此程式碼。您可能需要稍微修改程式碼，才能在 CodeCatalyst 中運作。如需詳細資訊，請參閱[新增「GitHub 動作」動作](integrations-github-action-add.md)。

1. （選用） 在工作流程中，**您可以新增其他動作**，例如建置和測試動作。如需詳細資訊，請參閱[使用工作流程建置、測試和部署使用工作流程建置、測試和部署](workflow.md)。

1. 您可以透過觸發手動或自動**啟動工作流程**。工作流程會執行 GitHub 動作和工作流程中的任何其他動作。如需詳細資訊，請參閱[手動啟動工作流程執行](workflows-manually-start.md)。

如需詳細步驟，請參閱：
+ [新增精選的 GitHub 動作](integrations-github-action-add-curated.md).
+ [新增「GitHub 動作」動作](integrations-github-action-add.md).

## GitHub 動作是否在 GitHub 中執行？
<a name="integrations-github-actions-where-it-runs"></a>

否。GitHub 動作會使用 CodeCatalyst 的[執行期環境映像](workflows-working-compute.md)，在 CodeCatalyst 中執行。

## 也可以使用 GitHub 工作流程嗎？
<a name="integrations-github-actions-workflows-support.title"></a>

否。

## 「GitHub 動作」動作所使用的執行期映像
<a name="integrations-github-actions-runtime"></a>

CodeCatalyst **GitHub 動作**會在 [2022 年 11 月映像](build-images.md#build.previous-image)上執行。如需詳細資訊，請參閱[作用中映像](build-images.md#build-curated-images)。