繁体   English   中英

Github 第二代 Google Functions 的操作

[英]Github Actions to Google Functions 2nd gen

我正在使用 Github Action 来部署 Google Functions。 我如何使用第二代而不是第一代?

这是我的代码:

.github/workflows/google-cloud-function.yaml

# This is a basic workflow to help you get started with Actions
name: CD

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [main]
  pull_request:
    branches: [main]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: "read"
      id-token: "write"
    steps:
      - name: checkout repo
        uses: actions/checkout@v2
      - id: "auth"
        name: "Authenticate to Google Cloud"
        uses: "google-github-actions/auth@v0"
        with:
          workload_identity_provider: "projects/12345/locations/global/workloadIdentityPools/gh-pool/providers/gh-provider"
          service_account: "github-actions-service-account@PROJECT.iam.gserviceaccount.com"
      - id: "deploy"
        uses: "google-github-actions/deploy-cloud-functions@v0"
        with:
          name: "myapp"
          runtime: "python310"
          region: "europe-west1"
          entry_point: "main"
          timeout: 540
          service_account_email: PROJECT@appspot.gserviceaccount.com
          ingress_settings: ALLOW_ALL
          max_instances: 1

      # Example of using the output
      - id: "test"
        run: 'curl "${{ steps.deploy.outputs.url }}"'

这就是我每次将更改推送到 Github 时将其设置为部署的方式:

Powershell:

$GITHUB_REPO="ORGANIZATION/{YOUR-REPO-NAME}"
$PROJECT_ID="PROJECT"
$SERVICE_ACCOUNT="github-actions-service-account"
$WORKLOAD_IDENTITY_POOL="gh-pool"
$WORKLOAD_IDENTITY_PROVIDER="gh-provider"

项目编号

gcloud config set project $PROJECT_ID

获取身份:

gcloud iam workload-identity-pools describe $WORKLOAD_IDENTITY_POOL --location="global" --format="value(name)"

--> projects/XXXX/locations/global/workloadIdentityPools/gh-pool

$WORKLOAD_IDENTITY_POOL_ID="projects/XXXX/locations/global/workloadIdentityPools/gh-pool"

连接存储库:

gcloud iam service-accounts add-iam-policy-binding $SERVICE_ACCOUNT@$PROJECT_ID.iam.gserviceaccount.com --role="roles/iam.workloadIdentityUser" --member="principalSet://iam.googleapis.com/${WORKLOAD_IDENTITY_POOL_ID}/attribute.repository/${GITHUB_REPO}"

我认为目前无法使用 Github Action 部署第二代云 function。 已经在github提出了这方面的要求,如下所述。

GitHub 仅部署云的操作 function 第一代。 我们目前不支持 Cloud Functions gen2。 如果您需要对 gen2 的支持,您可以使用 setup-gcloud 操作并手动运行gcloud命令。

您还可以在仍然未解决的 github 问题中添加您的关注,您可以关注该问题以获取更新,并且可以在那里跟踪进一步的进展。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM