Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add "pathPattern" as an event trigger filter #435

Open
mudassarzahid opened this issue Oct 3, 2024 · 4 comments
Open

Unable to add "pathPattern" as an event trigger filter #435

mudassarzahid opened this issue Oct 3, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@mudassarzahid
Copy link

TL;DR

I want to deploy a cloud function that is supposed to be triggered when a document is created in firebase. I get an error when trying to specify the path for the newly created document (the documentation is not very clear about how to specify the path in the yaml file, e.g. what are the possible attributes for event_trigger_filters?).

Expected behavior

No response

Observed behavior

No response

Action YAML

name: Deploy Workflow

on:
  push:

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest

    steps:
      - id: checkout
        name: Checkout
        uses: actions/checkout@v4

      - id: auth
        name: Authenticate to Google Cloud
        uses: google-github-actions/auth@v2
        with:
          token_format: access_token
          project_id: project-id
          workload_identity_provider: <workload-identity-provider>
          service_account: "deploy@project-id.iam.gserviceaccount.com"

      - name: Install dependencies
        run: npm install

      - name: Build
        run: npm run build

      - name: Deploy function-name
        uses: google-github-actions/deploy-cloud-functions@main
        with:
          name: function-name
          entry_point: function-name
          runtime: "nodejs20"
          region: "europe-west1"
          build_service_account: "build@project-id.iam.gserviceaccount.com"
          service_account: "run@project-id.iam.gserviceaccount.com"
          event_trigger_type: "google.cloud.firestore.document.v1.created"
          event_trigger_service_account: "run@project-id.iam.gserviceaccount.com"
          event_trigger_filters: |-
            pathPattern="projects/project-id/databases/firestore-name/documents/collection-name/{docId}"

Log output

Prepare all required actions
Getting action download info
Download action repository 'google-github-actions/deploy-cloud-functions@main' (SHA:a2164ef2fe5dcc9c1f49bb5297133b5ba5920af8)
Run ./.github/actions/deploy-cloud-function
Run google-github-actions/deploy-cloud-functions@main
Created zip file from './' at '/tmp/cfsrc-535549cdea9103c31dc3d38f.zip'
Updating existing Cloud Functions deployment
Error: google-github-actions/deploy-cloud-functions failed with: failed to PATCH https://cloudfunctions.googleapis.com/v2/projects/project-id/locations/europe-west1/functions/function-name?updateMask=name,environment,buildConfig.runtime,buildConfig.entryPoint,buildConfig.source,buildConfig.serviceAccount,serviceConfig.allTrafficOnLatestRevision,serviceConfig.availableMemory,serviceConfig.environmentVariables,serviceConfig.ingressSettings,serviceConfig.serviceAccountEmail,serviceConfig.timeoutSeconds,eventTrigger.eventType,eventTrigger.eventFilters,eventTrigger.serviceAccountEmail,eventTrigger.retryPolicy: (400) {
  "error": {
    "code": 400,
    "message": "Validation failed for trigger projects/project-id/locations/europe-west1/triggers/function-name-686621: The request was invalid: invalid argument: event type google.cloud.firestore.document.v1.created not supported: attribute pattern not found within event type",
    "status": "INVALID_ARGUMENT"
  }
}

Additional information

No response

@mudassarzahid mudassarzahid added the bug Something isn't working label Oct 3, 2024
@maxrinal
Copy link

hey @mudassarzahid I was able to make it work with the following code. To make it work, I've created the trigger at first deploying with the gcloud client, and starting comparing the result using describe.

          event_trigger_type: google.cloud.firestore.document.v1.written
          event_trigger_filters: |-
            database=some-database
            document=PATTERN:test_coll/{test_coll}

@sethvargo
Copy link
Member

Hi @mudassarzahid did @maxrinal's suggestion work?

@mudassarzahid
Copy link
Author

mudassarzahid commented Nov 14, 2024

Hi @sethvargo @maxrinal , thanks for the help! It took some experimenting but it finally worked using google-github-actions/deploy-cloud-functions@v3.0.7 and the document pattern filter. It doesn't work with google-github-actions/deploy-cloud-functions@main

@sethvargo
Copy link
Member

That doesn't make sense because at this time, all of those references point to the same Git SHA...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants