Skip to content

A Cloudflare worker for creating GitHub PRs for new course reviews for ubccsss.org's courses database. Reviews are verified using reCAPTCHA.

Notifications You must be signed in to change notification settings

ubccsss/course-review-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👷 Course review worker

A Cloudflare worker for creating GitHub PRs for new course reviews for ubccsss.org's courses database. Reviews are verified using reCAPTCHA.

Getting Started

$ git clone
$ cd course-review-worker
$ npm install
$ npm i @cloudflare/wrangler -g
$ wrangler login  # select y to login via browser

Environments

  • Development : default
  • Production : --env production

Environment Variables

Below are the environment variables that are used by the worker. Each one of them has a value for production and development. They can be set in wrangler.toml.

  • ENVIRONMENT : The environment the worker is running in
  • OWNER : owner of the GitHub repository
  • REPO : name of the GitHub repository
  • BASE_BRANCH : base branch of the GitHub repository
  • USERS : comma-separated list of user reviewers for the PR
  • TEAMS : comma-separated list of team reviewers for the PR
  • LABELS : comma-separated list of labels to apply to new PRs
  • ORIGIN : acceptable origin for requests to the worker

Secrets

Secrets can be managed using wrangler or using the Cloudflare dashboard.

Example call

const pr = await fetch(WORKER_URL, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    recaptcha: {
      token: token,
    },
    details: {
      course: course,
      user: user,
      review: review,
      reference: reference, 
      difficulty: difficulty,
      quality: quality,
      sessionTaken: sessionTaken, 
    },
  }),
})

Complete example call with error handling here.

Contributing

index.js contains the Worker's script.

wrangler.toml contains the worker's configuration.

Running the worker locally:

$ wrangler dev  # runs dev environment
$ wrangler dev --env production  # runs production envirnment

Publishing the worker to Cloudflare:

$ wrangler publish  # publishes dev environment
$ wrangler publish --env production  # publishes production environment

Further documentation on Cloudflare workers can be found here.

Further documentation on Wrangler can be found here.

About

A Cloudflare worker for creating GitHub PRs for new course reviews for ubccsss.org's courses database. Reviews are verified using reCAPTCHA.

Topics

Resources

Stars

Watchers

Forks