Skip to main content

Github

Github is the site where the world builds software.

Official Websitehttps://github.com/
Version2.0.10
Tagsrepository, code, source, git, github

Credential configuration

You'll need a personal access token to configure this credential. If you don't have one create it.

In the extra options field you can pass most of the params you can find here.

Here you have an example of a filled credential configuration form in YepCode:

Github snippets available in editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const githubClient = yepcode.integration.github('credential-slug')
New integration from plain authentication data
const { Octokit } = require("octokit");

const githubClient = new Octokit({ auth: 'your-personal-token' });

Create a repository

Create repository
const response = await githubClient.rest.repos
.createForAuthenticatedUser({
name: 'your-new-repository-name',
description: `Some description`,
private: true,
auto_init: true
// other props
})
console.log(`Created repository ${response.data.full_name}`);

Delete a repository

Delete repository
const response = await githubClient.rest.repos
.delete({
owner: 'repository-owner',
repo: 'repository-name',
})
console.log("Deleted repository");

Get a file from repository

Get file from repository
const response = await githubClient.rest.repos
.getContent({
mediaType: {
format: "raw",
},
owner: 'repository-owner',
repo: 'repository-name',
path: 'path-to-file',
})
console.log(response.data);

Get commits from repository

Get commits from repository
const response = await githubClient.rest.repos
.listCommits({
owner: 'repository-owner',
repo: 'repository-name',
per_page: page-size,
page: page-number,
})
const commits = response.data;
commits.forEach((commit) => console.log(`Found commit! ${commit.commit.message}`));

Get issues from repository

Get issues from repository
const response = await githubClient.rest.issues
.listForRepo({
owner: 'repository-owner',
repo: 'repository-name',
per_page: page-size,
page: page-number,
state: "open",
})
const issues = response.data;
issues.forEach((issue) => console.log(`Found issue! ${issue.title}`));

Create issue in a repository

Create issue in a repository
const response = await githubClient.rest.issues
.create({
owner: 'repository-owner',
repo: 'repository-name',
title: 'issue-title',
body: 'issue-body',
})
console.log(`Created issue! See it here: ${response.data.html_url}`);

Use GraphQL

Use GraphQL
const response = await githubClient
.graphql(
`
query theQuery($owner: String!, $repo: String!) {
theQuery(owner: $owner, name: $repo) {
// the query content
}
}
`,
{
owner: 'repository-owner',
repo: 'repository-name',
}
)