Last active
November 13, 2023 10:17
-
-
Save cbandy/b58d32fe44dcbaa91f35e821efb72066 to your computer and use it in GitHub Desktop.
Ignore everything except allowed files in .gcloudignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ignore everything | |
/[!.]* | |
/.?* | |
# Except the Cloud Function files we want to deploy | |
!/package.json | |
!/index.js | |
!/lib/** | |
#!include:.gitignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from googlecloudsdk.command_lib.util import gcloudignore | |
chooser = gcloudignore.GetFileChooserForDir('.') | |
predicate = chooser.IsIncluded | |
for root, _, filelist in os.walk('.'): | |
path = os.path.normpath(os.path.relpath(root, '.')) | |
if not predicate(path): | |
continue | |
for f in filelist: | |
filename = os.path.normpath(os.path.join(root, f)) | |
if not predicate(filename): | |
continue | |
print(filename) |
@jake-tulip this is late, and I don't know that you'll get a notification... I've tested the following with the above Python script:
!/dir/
!/dir/config/**
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cbandy do you know how to also exclude everything in a subdirectory except one directory.
So if we have:
index.js
package.json
dir/index.js
dir/.gitignore
dir/config/config.yaml
dir/config/config2.yaml
What would be the pattern to only deploy: