[英]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.