This repository supports GitHub operation API for manipulating branches and files in remote GitHub repositories. This API makes use of GitHub REST API and GitHub GraphQL API.
- Script: lib/gitOpsApi.js
Includes API for operating remote Github branches and files. All API functions return a promise. Refer to the JSDoc in the script for the detail of parameters.
- getBranchRef(octokit, options)
- getAllBranches(octokit, options)
- getDirInfo(octokit, options)
- createBranch(octokit, options)
- deleteBranch(octokit, options)
- fetchRemoteFile(octokit, options)
- getFileLastCommit(octokit, options)
- createSingleFile(octokit, options)
- updateSingleFile(octokit, options)
- deleteSingleFile(octokit, options)
- commitMultipleFiles(octokit, options)
- issuePullRequest(octokit, options)
Run npm ci
to install all dependencies.
Run npm run lint
to lint.
Run npm run test
to run tests.
Note that tests for Git operation API (tests/gitOpsApiTests.js
) is not included in npm run test
command. This test
requires a personal access token that has the privilege to operate
inclusive-design/git-ops-api.
This access token can be supplied by defining an environment variable named "ACCESS_TOKEN" or passed as an argument
when running the script node tests/gitOpsApiTests.js {access_token}
.
Create a .env
at the root directory with a content:
ACCESS_TOKEN={String}
-
Script: demos/fetchODCDataFiles.js
-
Goal: Check if a new version of the open dataset documenting COVID-19 assessment centre locations has been published on the Ontario Data Catalogue API. If the dataset has been updated, this script downloads the file, updates the corresponding latest.json, and commits them into COVID assessment centres data repository.
-
Prerequisites: Tasks below need to complete before running the script:
- Define an environment variable
ACCESS_TOKEN
: The personal access token of a Github account that commits will be issued on behalf. Refer to the Github documentation about how to create a Github personal access token. - Visit the config file to set proper config values. Purpose of these values are explained in the config file.
- Define an environment variable
-
How to run:
node demos/fetchODCDataFiles.js