google-github-actions / deploy-cloud-functions

A GitHub Action that deploys source code to Google Cloud Functions.
https://cloud.google.com/functions
Apache License 2.0
318 stars 66 forks source link

Using labels with no value fails #392

Closed BoscoDomingo closed 10 months ago

BoscoDomingo commented 1 year ago

TL;DR

You can't use labels without a value. Even a label= fails

Expected behavior

I would expect to be able to deploy a function with a label that contains a simple key with no value as I can via Console or CLI: image

Observed behavior

I got the errors failed to parse KEY=VALUE pair "REDACTED_KEY=": no value and failed to parse KEY=VALUE pair "REDACTED_KEY": missing "=". This comes from https://github.com/google-github-actions/actions-utils/blob/main/src/kv.ts#L50

Action YAML

- id: 'deploy'
        uses: 'google-github-actions/deploy-cloud-functions@v1'
        env:
          GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID_DEV }}
          GCP_SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT_DEV }}
        with:
          project_id: ${{env.GCP_PROJECT_ID}}
          name: 'REDACTED'
          runtime: 'nodejs${{env.NODE_VERSION}}'
          entry_point: 'main'
          region: ${{env.REGION}}
          docker_registry: 'artifact-registry'
          env_vars: REDACTED
          env_vars_file: '.github/workflows/env.yml'
          secret_environment_variables: REDACTED
          service_account_email: ${{ env.GCP_SERVICE_ACCOUNT }}
          labels: 'REDACTED_KEY' # can also try with 'REDACTED_KEY='

Log output

Private log, the only relevant parts are the error messages I provided

Additional information

It is pertinent to your library used for parsing Key-Value pairs, but in this case, it should allow value-less pairs as is permitted in GCP via Console or CLI as mentioned.

BoscoDomingo commented 1 year ago

I've opened a PR on the actions-utils repo that would allow this change to work.

If approved, I could then create a PR in this repo for the small change that would be required for this usecase

sethvargo commented 1 year ago

Does this work via the gcloud CLI? The documentation indicates both KEY and VALUE are required (there are no brackets around VALUE indicating optionality.

deriegle commented 1 year ago

This is a similar/duplicate issue as #379 that I created ~6 months ago.

Thanks for creating the PR against the utils repo. Hopefully we can get some traction on this.

BoscoDomingo commented 1 year ago

Does this work via the gcloud CLI? The documentation indicates both KEY and VALUE are required (there are no brackets around VALUE indicating optionality.

@sethvargo Great question, I haven't actually tried. It 100% does on the Console as I showed, however, so I would be surprised if the CLI didn't allow for it unless code was specifically written to avoid that case for whatever reason, or something like this situation where it was simply not taken into account. If I have time tomorrow I'll try to give it a go and report back 👍🏼

BoscoDomingo commented 10 months ago

This will be solved by @sethvargo's https://github.com/google-github-actions/actions-utils/pull/91 (haven't checked if it has been integrated to this Action yet, but wanted to link the 2 things together)

sethvargo commented 10 months ago

Not yet, was gonna try to get to it tonight, but my flight got delayed.