This file contains 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
export const MY_CONST = 'ESM'; |
This file contains 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: Deploy Cloud Workflow | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy Cloud Workflow | |
runs-on: ubuntu-18.04 | |
steps: |
This file contains 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
# Add secret for project | |
PROJECT=$(gcloud config get-value project) | |
gh secret set GCP_PROJECT_ID -b $PROJECT | |
# Create service account | |
SERVICE_ACCOUNT=my-wf-service-account | |
gcloud iam service-accounts create $SERVICE_ACCOUNT | |
gcloud projects add-iam-policy-binding $PROJECT \ | |
--member "serviceAccount:$SERVICE_ACCOUNT@$PROJECT.iam.gserviceaccount.com" \ | |
--role "roles/workflows.editor" |
This file contains 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
- getCurrentTime: | |
call: http.get | |
args: | |
url: https://us-central1-workflowsample.cloudfunctions.net/datetime | |
result: currentTime | |
- readWikipedia: | |
call: http.get | |
args: | |
url: https://en.wikipedia.org/w/api.php | |
query: |
This file contains 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
// 1. Load the JavaScript client library. | |
gapi.load('client', init); | |
async function init() { | |
// 2. Initialize the JavaScript client library. | |
await gapi.client.init({ | |
discoveryDocs: ['https://discovery.googleapis.com/$discovery/rest'] | |
}); | |
start(); | |
} |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Hello, GAPI</title> | |
</head> | |
<body> | |
Hello, GAPI! | |
<script src="https://apis.google.com/js/api.js"></script> | |
</body> | |
</html> |
This file contains 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 Cloud Run URL | |
ENDPOINT=$(\ | |
gcloud run services list \ | |
--project=${PROJECT} \ | |
--region=${REGION} \ | |
--platform=managed \ | |
--format="value(status.address.url)" \ | |
--filter="metadata.name=grpc-calculator") | |
ENDPOINT=${ENDPOINT#https://} && echo ${ENDPOINT} |
This file contains 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
function calculate(call, callback) { | |
const request = call.request; | |
let result; | |
if (request.operation === 'ADD') { | |
result = request.first_operand + request.second_operand; | |
} else { | |
result = request.first_operand - request.second_operand; | |
} | |
callback(null, {result}); | |
} |
This file contains 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
function main() { | |
const server = new grpc.Server(); | |
server.addService(calculatorProto.Calculator.service, {calculate}); | |
server.bindAsync(`0.0.0.0:${PORT}`, grpc.ServerCredentials.createInsecure(), (error, port) => { | |
if (error) { | |
throw error; | |
} | |
server.start(); | |
}); | |
} |
This file contains 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
enum Operation { | |
ADD = 0; | |
SUBTRACT = 1; | |
} | |
message BinaryOperation { | |
float first_operand = 1; | |
float second_operand = 2; | |
Operation operation = 3; | |
}; | |
message CalculationResult { |