deploy-cloud-functions
deploy-cloud-functions copied to clipboard
Ability to create 2nd Gen functions
TL;DR
I'd love to take advantage of the new 2nd Gen cloud functions, and it'd be great to deploy them with github actions. Ideally, I'd like to specify the generation of the cloud function as an input in the yaml. Is there currently any way to deploy a 2nd Gen cloud function with a github action, using this repo or another one?
Detailed design
Something like `gen: 2` as an input option would be perfect
Additional information
No response
Thanks for the FR @vishnumenon We will need to update this action to support the v2 endpoint. In the interim, you should be able to use setup-gcloud and https://cloud.google.com/sdk/gcloud/reference/beta/functions/deploy#--gen2 as a workaround.
@bharathkkb Sounds good, I'll give that approach a try! Thanks!
@bharathkkb Is there an update on when this Action will support the ability to set it to deploy using Gen2?
Hi @jwilksy
Cloud Functions are still in Preview (https://cloud.google.com/functions/docs/2nd-gen/overview).
Has someone information about release date 2ng generation?
This is now in GA - https://cloud.google.com/blog/products/serverless/cloud-functions-2nd-generation-now-generally-available
Can the maintainers provide an update on if/when this will be supported? Thanks!
I created this PR to see if we can have this available through this action. I'm available to contribute to this. Please let me know what else is necessary here.
This feature would be tremendously helpful. Any ETA on this?
+1 would be super helpful to have this as part of the existing github action
@sethvargo +100500 this is also extremely useful feature (and this https://github.com/google-github-actions/deploy-cloud-functions/issues/350)
It is unclear when Google Cloud Repositories will support Cloud Functions gen 2 that is why Deploy Cloud Functions actions is only one options for convenient deployment.
Right now i see errors related to Functions gen 2 like: cannot create a function
We do not currently support Cloud Functions gen2. If you need support for gen2, you can use the setup-gcloud
action and run a gcloud
command manually.
We do not currently support Cloud Functions gen2. If you need support for gen2, you can use the
setup-gcloud
action and run agcloud
command manually.
@sethvargo I think most of us in this thread understand this is not currently supported and the possible alternative(s). I think we'd more like to know if this would be available in the near future vs. later (next weeks vs. months/years), so we can accordingly plan to rewrite our pipelines or simply hold off until the feature becomes available within github actions itself.
If you are interested in Cloud Functions gen 2 and perhaps you write in Go, then it is ok to configure following Github Actions:
- Google Cloud Platform Auth (workload identity provider)
- Set up Cloud SDK (gcloud cli)
and your deployment command might look like
gcloud functions deploy my-cloud-function --gen2 --runtime=go119 --region=us-central1 --source=.
having configured alternatives, i could say that options above are much easier to configure than others.
2gen is no longer beta yes? :)
yes, they are good for production now.
Any news?
@maxpain i would suggest you use gcloud
tool and a little bit of custom steps in GitHub Actions pipelines. It is pretty easy and works well for awhile.
I made its working by using gcloud
Here is an example:
steps:
- uses: actions/checkout@v3
- run: ls
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/${{ vars.PROJECT_NUMBER }}/locations/global/workloadIdentityPools/idpool/providers/idprovider'
service_account: ${{ vars.GCP_GITHUB_SERVICE_ACCOUNT }}
token_format: 'access_token'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
with:
version: '>= 363.0.0'
- name: 'Use gcloud CLI'
run: 'gcloud info'
- name: 'Use to deploy a cloud function gen 2'
run: 'gcloud functions deploy httptest1 --gen2 --runtime=nodejs18 --region=us-central1 --source=backend/service-secured-test --trigger-http --allow-unauthenticated --entry-point=helloHttp --memory=256MB --timeout=60s'
@sethvargo @bharathkkb are you planning to add support for this in the (near) future?
So I have to use a workaround to deploy a gen2 function? It shouldn't be this hard to add CD to a cloud function.
+1 i'd be very interested on this too 😄
above you can find solutions for Golang and Node, nothing difficult to use that for other runtimes.
I made it working by using
gcloud
can we still have the curl for testing the output URL? @vyshkov
I made it working by using
gcloud
can we still have the curl for testing the output URL?
It's not pretty, but you should be able to get the URL via the gcloud functions describe
utility
For example
- nam: Get url
id: get-url
run: echo "url=$(gcloud functions describe function-name-here --gen2 --region europe-west2 --format json | jq .url -r)" >> $GITHUB_OUTPUT
Just make sure you get the name and region right
The above step will store the url of the function under "url" which you can reference like this
${{ steps.get-url.outputs.url }}
Any ETA on 2nd gen support?
@fa-aman I recommend just switching to the gcloud action like @vyshkov proposes above, it's basically the same syntax but without the limitation on gen1
I would love to contribute to the gen2 feature support if it's just a concern of bandwidth and no other technical or roadmap limitations @sethvargo @bharathkkb. Let us know, please.
Nudge on the 2nd gen pls…or I guess if you can point to a interim solution, thank you
+1 on this too, support for 2nd gen would help us a lot