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

"Failed to upload zip file" error

Open lcareto opened this issue 1 year ago • 1 comments

TL;DR

When uploading the code from source, getting the "The file at *** does not exist, or it is not a file" error while the zip file seems to exist after running ls -1 /tmp | grep .zip

Screenshot 2024-09-13 at 11 49 47 AM

Expected behavior

No zip file error

Observed behavior

Error: google-github-actions/deploy-cloud-functions failed with: failed to upload zip file: The file at *** does not exist, or it is not a file. ENOENT: no such file or directory, lstat '/home/runner/work/my-functions/my-functions/***

Action YAML

name: Deploy All Functions

on:
  push:
    branches:
      - main
jobs:

  deploy:
    runs-on: ubuntu-latest
    name: Deploy
    permissions:
      contents: "read"
      id-token: "write"
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js 22.8.0
        uses: actions/setup-node@v4
        with:
          node-version: 22.8.0
          cache: 'yarn'

      - name: Install
        run: yarn install

      - name: Build
        run: yarn run build

      - uses: google-github-actions/auth@v2
        with:
          credentials_json: ${{ secrets.GCP_SA_KEY }}

      - name: Deploy 
        timeout-minutes: 10
        continue-on-error: true
        uses: google-github-actions/deploy-cloud-functions@v3
        with:
          name: "my-function"
          runtime: "nodejs22"
          source_dir: "./functions/my-function"
          entry_point: "exec"
          max_instance_count: 3
          event_trigger_type: "google.pubsub.topic.publish"
          event_trigger_pubsub_topic: "projects/my-project/topics/my-topic"
        env:
          GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GCP_SA_KEY }}

      - run: ls -1 /tmp | grep .zip

Log output

Cf. screenshot in TLDR

Additional information

Note my folder structure

/my-cloud-functions-repo
  /functions
    /my-function
      index.ts
      package.json
  tsconfig.json 
  package.json

the root package.json contains the following script and some shared dependencies

    "build": "tsc -b functions/*",
    "gcp-build":""

the my-function package json contains the following

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "noEmit": false,
    "outDir": "../../.",
  },
  "include": [
    "**/*.ts"
  ]
}

when running yarn run build at the root, the functions/my-function/index.js will be created

lcareto avatar Sep 13 '24 16:09 lcareto