简体   繁体   English

Github 第二代 Google Functions 的操作

[英]Github Actions to Google Functions 2nd gen

I am using Github Action in order to deploy Google Functions.我正在使用 Github Action 来部署 Google Functions。 How can I use the second generation, instead of the first generation?我如何使用第二代而不是第一代?

This is my code:这是我的代码:

.github/workflows/google-cloud-function.yaml .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 }}"'

This is how I set it up to be deployed everytime I push changes to Github:这就是我每次将更改推送到 Github 时将其设置为部署的方式:

Powershell: 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"

Project ID项目编号

gcloud config set project $PROJECT_ID

Get 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"

Connect repository:连接存储库:

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}"

I think currently it is not possible to deploy a 2nd Gen cloud function with a Github Action.我认为目前无法使用 Github Action 部署第二代云 function。 There is already request raised for this at github which is mentioned like below.已经在github提出了这方面的要求,如下所述。

GitHub Actions only to deploy cloud function 1st gen. GitHub 仅部署云的操作 function 第一代。 We do not currently support Cloud Functions gen2.我们目前不支持 Cloud Functions gen2。 If you need support for gen2, you can use the setup-gcloud action and run a gcloud command manually.如果您需要对 gen2 的支持,您可以使用 setup-gcloud 操作并手动运行gcloud命令。

you may also add your concern in that github issue which is still open, you can follow that issue for updates and further progress can be tracked there.您还可以在仍然未解决的 github 问题中添加您的关注,您可以关注该问题以获取更新,并且可以在那里跟踪进一步的进展。

暂无
暂无

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

相关问题 将谷歌云 function 2nd gen 连接到另一个项目的 mysql - Connect google cloud function 2nd gen to mysql of another project 云 function,第二代并发? - Cloud function, 2nd gen concurrency? 带有 Firebase 数据库触发器的第二代 Google Cloud Functions - Google Cloud Functions 2nd Generation with Firebase Database trigger 对于需要服务帐户身份验证的 GCP 云 function 第二代,在 IAMCredentialsClient 中使用的正确 scope 是什么? - What is the proper scope to use in IAMCredentialsClient for a GCP cloud function 2nd gen that requires authentication from a service account? 使用 github 操作部署 firebase 云功能 - Deploying firebase cloud functions using github actions Firebase 功能第二代 - 运行时隐私和安全 - Firebase functions 2nd generation - runtime privacy and safety Github 对 Google Cloud Functions 的操作“Constraint constraints/gcp.resourceLocations violated for projects/GOOGLE_PROJECT_ID attempted GenerateU - Github Actions to Google Cloud Functions "Constraint constraints/gcp.resourceLocations violated for projects/GOOGLE_PROJECT_ID attempting GenerateU 如何部署 Google Cloud Function(第 2 代)? - How do I deploy a Google Cloud Function (2nd generation)? 用于 github 操作的 Google 服务 json 文件? - Google services json file for github actions? 使用 gcloud 命令部署事件弧触发第二代云 function 时如何指定 pubsub 主题 - How to specify pubsub topic when deploying event arc triggered 2nd gen cloud function using gcloud command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM