- Type: full code example
- Language: javascript, node.js
- Demo: update an existing gist:
createa new file in a gisteditthe content of a gist file
- Github
personal access token - Run:
npm i @octokit/corein terminal
create a new file in a gistedit the content of a gist filepersonal access tokennpm i @octokit/core in terminal| const { Octokit } = require('@octokit/core'); | |
| // process.env.GITHUB_TOKEN = personal access token from your Github account | |
| const token = process.env.GITHUB_TOKEN | |
| // gistId = the specific id of a gist (found in url) | |
| let gistId = '{INPUT_GIST_ID}' | |
| const octokit = new Octokit({ | |
| auth: token, | |
| }) | |
| octokit | |
| .request(`PATCH /gists/${gistId}`, { | |
| gist_id: gistId, | |
| description: 'description test1', | |
| files: { 'test1.md': { content: 'content test1' } }, | |
| }) | |
| .then((rs) => console.log(rs)); |