deploy-cloud-functions icon indicating copy to clipboard operation
deploy-cloud-functions copied to clipboard

Add 2nd gen function support

Open igor-imaginemage opened this issue 1 year ago • 13 comments

As discussed in https://github.com/google-github-actions/deploy-cloud-functions/issues/304, it would be great to have gen2 functions support through this GitHub action without needing any further action rather than just specifying through an input value if we want to use or not second gen functions.

There are many advantages in favor of using 2nd gen functions, so I believe this is something most of us as devs will need.

This PR is adding a new gen2 input that will read the gen2 value (1 or 0) and add it to the request when deploying a cloud function.

The README file was updated having this new input field on the list of available inputs.

igor-imaginemage avatar Aug 29 '22 15:08 igor-imaginemage

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Aug 29 '22 15:08 google-cla[bot]

@igor-imaginemage do you have any concerns about signing the CLA? I would love to see this one merged.

foreverest avatar Sep 18 '22 07:09 foreverest

@foreverest, I can sign it. But what I added to this PR is just the beginning of what we have to adjust on this repository. I was trying to advance it more on my local tests, but as I commented here (https://github.com/googleapis/nodejs-functions/issues/62), I'm stuck on the API call where we create a gen2 function. The example Google provides doesn't have the payload, so I'm getting some random errors and as the error message isn't clear of what's going on I'm having difficulties proceeding.

Is this something you can check if you are able to help me? If I get an example of how we should make this API call I can work on the actions script and make it compatible with gen2 functions.

igor-imaginemage avatar Sep 19 '22 13:09 igor-imaginemage

@foreverest I signed it but it's still showing as not signed even after the rescan.

igor-imaginemage avatar Sep 19 '22 13:09 igor-imaginemage

Hi @igor-imaginemage what email address did you use? The commits are signed with [email protected], so it's going to look for a CLA signed by that email address.

sethvargo avatar Sep 19 '22 13:09 sethvargo

[email protected]. Once I submitted the CLA form I got the email to sign in. image

I noticed that [email protected] wasn't the primary e-mail address when I pushed this commit. I changed my account to use [email protected] as the primary e-mail address now, so I'm not sure if it's related to that.

igor-imaginemage avatar Sep 19 '22 13:09 igor-imaginemage

There are any updates? I would really like it to be merged

gopob avatar Sep 22 '22 10:09 gopob

I would also like to see this merged! I've converted a number of functions over to 2nd Gen for my project, but now I'm struggling without good CI/CD support for deploying.

ryanwoconnor avatar Oct 01 '22 18:10 ryanwoconnor

@foreverest, I can sign it. But what I added to this PR is just the beginning of what we have to adjust on this repository. I was trying to advance it more on my local tests, but as I commented here (googleapis/nodejs-functions#62), I'm stuck on the API call where we create a gen2 function. The example Google provides doesn't have the payload, so I'm getting some random errors and as the error message isn't clear of what's going on I'm having difficulties proceeding.

Is this something you can check if you are able to help me? If I get an example of how we should make this API call I can work on the actions script and make it compatible with gen2 functions.

@sethvargo can you help me with this?

igor-imaginemage avatar Oct 05 '22 07:10 igor-imaginemage

HI, Any eta? on merging the pr? we are in need on gen2 action as well, we need to make decision whether to create our own or wait for your PR to be merged.

alexgocariq avatar Oct 06 '22 17:10 alexgocariq

Our workaround has been to use the gcloud cli in a github action, however this will require your deploying service account to have some additional permissions

jobs:
  job_id:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3

    - id: auth
      uses: google-github-actions/auth@v0
      with:
        credentials_json: '${{ secrets.SERVICE_ACCOUNT_CREDENTIALS }}'

    - name: 'Set up Cloud SDK'
      uses: 'google-github-actions/setup-gcloud@v0'

    - id: 'deploy'
      run: > 
        gcloud
        functions
        deploy
        my-function
        --region=europe-north1
        --source=.
        --runtime=nodejs16
        --gen2

gerbal avatar Oct 06 '22 18:10 gerbal

That could be a valid workaround for my use case @gerbal. However are you able to also specify the source in that action? Say for example if I have several functions in my repo.

ryanwoconnor avatar Oct 07 '22 01:10 ryanwoconnor

@gerbal's workaround is sufficient for me so I'm using that workaround. This would still be a great PR to get merged though eventually.

ryanwoconnor avatar Oct 11 '22 01:10 ryanwoconnor

Could we get a timeline on when we can expect this to be merged / or have a feature like this available? Since this would help our workflow / deploy pipelines tremendously.

akshayshippy avatar Nov 08 '22 18:11 akshayshippy