deploy-cloud-functions
deploy-cloud-functions copied to clipboard
Re-including files in .gcloudignore does not work
TL;DR
google-github-actions/deploy-cloud-functions cannot re-include files in .gcloudignore with !PATH syntax as gcloud CLI does.
Expected behavior
With the following context:
.gcloudignore:
#!include:.gitignore
!build/**
.gitignore:
build
... files in build directory should be deployed (not ignored), as gcloud CLI handles in that way.
Observed behavior
google-github-actions/deploy-cloud-functions ignores files in build directory.
Action YAML
name: Some service
on:
pull_request:
paths:
- 'some-service/**'
- '.github/workflows/some-service.yml'
push:
branches:
- main
paths:
- 'some-service/**'
- '.github/workflows/some-service.yml'
defaults:
run:
working-directory: some-service
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- id: yarn-cache-directory
run: echo "::set-output name=value::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-directory.outputs.value }}
key: some-service-yarn-${{ hashFiles('some-service/yarn.lock') }}
restore-keys: |
some-service-yarn-
- run: yarn install
- run: yarn build
- run: yarn lint
release:
name: Release
runs-on: ubuntu-latest
needs: test
# if: github.event_name == 'push'
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- id: yarn-cache-directory
run: echo "::set-output name=value::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-directory.outputs.value }}
key: some-service-yarn-${{ hashFiles('some-service/yarn.lock') }}
restore-keys: |
some-service-yarn-
- run: yarn install
- run: yarn build
- uses: my-company/some-repo/actions/setup-gcloud@main
with:
project_id: some-project
- uses: google-github-actions/deploy-cloud-functions@v0
with:
source_dir: some-service
name: some-service
entry_point: someFunction
project_id: some-project
region: asia-northeast1
runtime: nodejs16
ingress_settings: ALLOW_ALL
service_account_email: [email protected]
env_vars_file: some-service/.env.staging.yml
Log output
Run google-github-actions/deploy-cloud-functions@v0
18
Created zip file from 'some-service' at '/tmp/cfsrc-fd98e351c011abcf46283d02.zip'
19
Creating new Cloud Function revision
20
Deploying Cloud Function
21
Still deploying Cloud Function (1/n)
22
Still deploying Cloud Function (2/n)
23
Still deploying Cloud Function (3/n)
24
Still deploying Cloud Function (4/n)
25
Still deploying Cloud Function (5/n)
26
Still deploying Cloud Function (6/n)
27
Still deploying Cloud Function (7/n)
28
Still deploying Cloud Function (8/n)
29
Still deploying Cloud Function (9/n)
30
Still deploying Cloud Function (10/n)
31
Still deploying Cloud Function (11/n)
32
Still deploying Cloud Function (12/n)
33
Still deploying Cloud Function (13/n)
34
Still deploying Cloud Function (14/n)
35
Still deploying Cloud Function (15/n)
36
Still deploying Cloud Function (16/n)
37
Still deploying Cloud Function (17/n)
38
Error: google-github-actions/deploy-cloud-functions failed with: operation failed: Build failed: build/index.js does not exist; Error ID: 7da9f5bc
Additional information
Repro project: https://github.com/yujinakayama/gcloudignore-issue
- Run
gcloud meta list-files-for-uploadforgcloudCLI behavior - Run
npm run test_github_actions_ignoreforgoogle-github-actions/deploy-cloud-functionsbehavior
Hi @yujinakayama
Thank you for opening an issue. I spent some time digging into this, and I think this is a bug in the upstream ignore library. I was able to reproduce this issue using just that library. Of note, it appears to be the trailing '**' that is mismatching:
const ignorer = ignore().add(['build', '!build/**']);
console.log(ignorer.ignores('build/index.js')); // true
const ignorer = ignore().add(['build', '!build']);
console.log(ignorer.ignores('build/index.js')); // false
I filed this issue upsteam: https://github.com/kaelzhang/node-ignore/issues/80
Hi there - the upstream author replied and says this is working as intended, mirroring how git and gitignore works. Their recommendation is to use !build instead of !build/**. That should work for both this and gcloud.