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
{ | |
"name": "run-workflow-function", | |
"main": "index.js", | |
"scripts": { | |
"start": "functions-framework --target=runWorkflow" | |
}, | |
"dependencies": { | |
"@google-cloud/functions-framework": "^1.7.1", | |
"@google-cloud/workflows": "^1.1.0" | |
} |
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
const vision = require('@google-cloud/vision'); | |
const visionClient = new vision.ImageAnnotatorClient(); | |
const {Firestore} = require('@google-cloud/firestore'); | |
const firestore = new Firestore(); | |
const trackedAnimals = ['raccoon', 'alpaca', 'peacock', 'dog', 'gecko', 'squirrel', 'red panda']; | |
/** | |
* Triggered from a change to a Cloud Storage bucket. |
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
const path = require('path'); | |
const {google} = require('googleapis'); | |
const sheets = google.sheets('v4'); | |
// TODO: Add your Sheet ID | |
// https://docs.google.com/spreadsheets/d/2L2LpYPyxJQTf14OLM6mVuiou88MsEi4Q-IUUxswNlfe/edit | |
const SPREADSHEET_ID = '2L2LpYPyxJQTf14OLM6mVuiou88MsEi4Q-IUUxswNlfe'; | |
/** | |
* Appends row data to the Google Sheet |
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
{ | |
"name": "sheets-on-run", | |
"main": "index.js", | |
"scripts": { | |
"start": "functions-framework --target=addRow" | |
}, | |
"dependencies": { | |
"@google-cloud/functions-framework": "^1.6.0", | |
"googleapis": "^58.0.0" | |
} |
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
# Install devtools, specifying a CRAN mirror | |
install.packages("devtools", repos='http://cran.us.r-project.org') | |
# Import devtools | |
library(devtools) | |
# Install GitHub project | |
install_github("averikitsch/functions-framework-r/src/functionsframework") |
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
# Set env var "GCP_PROJECT" to our project name | |
GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null) | |
# Build and upload your image in Google Container Registry | |
gcloud builds submit \ | |
--tag gcr.io/$GCP_PROJECT/hellor \ | |
--timeout="20m" | |
# Deploy your container to Cloud Run | |
gcloud run deploy hellor \ |
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
# Use an R image. | |
# https://hub.docker.com/r/rocker/r-ver/ | |
FROM rocker/r-ver:3.6.1 | |
# Copy R package binary | |
COPY functionsframework_*.tgz / | |
# Install functions framework dependencies. | |
RUN R -e "install.packages('functionsframework_0.0.0.9000.tgz', repos = NULL, type = 'source')" | |
RUN R -e "install.packages(c('optparse', 'plumber'))" |
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
# Get the current project | |
PROJECT=$(gcloud config get-value core/project 2> /dev/null) | |
# Create a service account (aka robot account) | |
gcloud iam service-accounts create sa-name \ | |
--description="sa-description" \ | |
--display-name="sa-display-name" | |
# Create and download credentials for the service account | |
gcloud iam service-accounts keys create creds.json \ |
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
> swift --version | |
Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53) | |
Target: x86_64-apple-darwin19.5.0 |
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
# Set project to current project in gcloud | |
PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null) | |
# Build the container using Cloud Build, giving plenty of time for the `swift build` step | |
gcloud builds submit --tag gcr.io/$PROJECT/vapor --timeout="20m" | |
# Run the container | |
gcloud run deploy vapor --image gcr.io/$GCP_PROJECT/vapor --platform managed --allow-unauthenticated |