- Type: full code example
- Language: javascript, node.js
- Demo: update an existing gist:
create
a new file in a gistedit
the content of a gist file
- Github
personal access token
- Run:
npm i @octokit/core
in terminal
create
a new file in a gistedit
the content of a gist filepersonal access token
npm i @octokit/core
in terminalconst { 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)); |