# NOT RUN {
cr_project_set("my-project")
cr_bucket_set("my-bucket")
cloudbuild <- system.file("cloudbuild/cloudbuild.yaml",
package = "googleCloudRunner"
)
bb <- cr_build_make(cloudbuild)
# repo hosted on GitHub
gh_trigger <- cr_buildtrigger_repo("MarkEdmondson1234/googleCloudRunner")
# repo mirrored to Cloud Source Repositories
cs_trigger <- cr_buildtrigger_repo("github_markedmondson1234_googlecloudrunner",
type = "cloud_source"
)
# }
# NOT RUN {
# build with in-line build code
cr_buildtrigger(bb, name = "bt-github-inline", trigger = gh_trigger)
# build with in-line build code using Cloud Source Repository
cr_buildtrigger(bb, name = "bt-github-inline", trigger = cs_trigger)
# build pointing to cloudbuild.yaml within the GitHub repo
cr_buildtrigger("inst/cloudbuild/cloudbuild.yaml",
name = "bt-github-file", trigger = gh_trigger
)
# build with repo mirror from file
cr_buildtrigger("inst/cloudbuild/cloudbuild.yaml",
name = "bt-cs-file", trigger = cs_trigger
)
# }
# NOT RUN {
# creating build triggers that respond to pubsub events
# }
# NOT RUN {
# create a pubsub topic either in webUI or via library(googlePubSubR)
library(googlePubsubR)
pubsub_auth()
topics_create("test-topic")
# }
# NOT RUN {
# create build trigger that will work from pub/subscription
pubsub_trigger <- cr_buildtrigger_pubsub("test-topic")
pubsub_trigger
# }
# NOT RUN {
# create the build trigger with in-line build
cr_buildtrigger(bb, name = "pubsub-triggered", trigger = pubsub_trigger)
# create scheduler that calls the pub/sub topic
cr_schedule("cloud-build-pubsub",
"15 5 * * *",
pubsubTarget = cr_schedule_pubsub("test-topic")
)
# }
# NOT RUN {
# create a pubsub trigger that uses github as a source of code to build upon
gh <- cr_buildtrigger_repo("MarkEdmondson1234/googleCloudRunner")
blist <- cr_build_make(cr_build_yaml(cr_buildstep_r('list.files()')))
# }
# NOT RUN {
cr_buildtrigger(blist,
name = "pubsub-triggered-github-source",
trigger = pubsub_trigger,
sourceToBuild = gh)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab