Cloud Run Jobs Demo
Downloading Starred Repositories
This project is a demonstration of how to use Google Cloud Run Jobs to periodically download and update a user's starred repositories from the GitHub API. It includes a sample Cloud Run Job that uses the GitHub API to fetch the list of repositories starred by a specified user and log them in order to route those logs to a sink such as BigQuery.
Prerequisites
To run the demo, you will need:
- A Google Cloud account with access to the Google Cloud Run, Cloud Workflow, and Cloud Scheduler services.
- The Google Cloud SDK, which includes the gcloud command-line tool for managing Google Cloud resources.
- A GitHub personal access token with the public_repo scope, which will be used to authenticate the GitHub API requests.
Running the demo
To run the demo, follow these steps:
Clone or download the Cloud Run Jobs Demo repository to your local machine. Open a terminal and navigate to the root directory of the project.
git clone https://github.com/veggiemonk/cloud-run-jobs-demo
cd cloud-run-jobs-demo
Locally
Set the environment variable GITHUB_TOKEN
to your GitHub personal access token:
./build.sh
export GITHUB_TOKEN=<your-github-token>
./bin/batch --username <your-github-username> --github-token $GITHUB_TOKEN
In Cloud Run
Use the gcloud tool to authenticate and set your default project and region:
gcloud auth login
gcloud config set project <your-project-id>
gcloud config set run/region <your-preferred-region>
Read the
setup.sh
script to understand what is needed to run the demo.
cat setup.sh
Here is a sample of what will be deployed:
Start presentation
go get golang.org/x/tools/cmd/present # install present binary in your $GOPATH
make presentation
Resources
- 3 ways to embed a commit hash in Go programs
- Learning Go by examples Series by Aurélie Vache
- The best Go framework
- Go structured logging proposal
- Run bash script in Cloud Build
- Cloud Run container contract
- LibHunt Go
- OSS Insight