Best JavaScript code snippet using argos
github-app.js
Source:github-app.js
...74 // Because of this we will reinit stuff by simply calling init again. 75 init();76}77// Retrieve an octokit instance78function getAppOctokit(issueRef) {79 // We need to find a match for issueRef owner based on account.login80 const r = appInstallations.findIndex(inst => inst.account.login == issueRef.owner);81 if (r != -1) {82 logger.debug("Found installation. Installation Id: " + appInstallations[r].id);83 return appInstallations[r].octokit;84 } else {85 logger.warn("Could not find app installation for owner: " + issueRef.owner);86 // Let's return an anonymous .87 return null;88 }...
github.ts
Source:github.ts
...14 },15 }),16)17export async function authenticateApp({ githubUrl }): Promise<Octokit> {18 const appOctokit = getAppOctokit()19 const installationRes = await appOctokit.apps.getRepoInstallation({20 ...parseGithubUrl(githubUrl),21 })22 const installationId = installationRes.data.id23 const { token = '' } = (await appOctokit.auth({24 type: 'installation',25 installationId,26 })) as any27 return new Octokit({ auth: token })28}29export async function deleteBranch(octokit: Octokit, { githubUrl, name }) {30 console.log('deleting branch ' + name)31 return await octokit.git.deleteRef({32 ...parseGithubUrl(githubUrl),33 ref: `heads/${name}`,34 })35}36export const getGithubAppName = memoizee(37 async () => {38 const octokit = getAppOctokit()39 // console.log(octokit.auth)40 const res = await octokit.apps.getAuthenticated({})41 // console.log(res.data)42 return res.data.slug43 },44 { promise: true },...
client.js
Source:client.js
1import { Octokit } from "@octokit/rest";2import { createOAuthAppAuth } from "@octokit/auth-oauth-app";3import { createAppAuth } from "@octokit/auth-app";4import config from "@argos-ci/config";5export function getAppOctokit() {6 return new Octokit({7 debug: config.get("env") === "development",8 authStrategy: createAppAuth,9 auth: {10 appId: config.get("github.appId"),11 privateKey: config.get("github.privateKey"),12 },13 });14}15export function getTokenOctokit(token) {16 return new Octokit({17 debug: config.get("env") === "development",18 auth: token,19 });20}21export function getOAuthOctokit() {22 return new Octokit({23 authStrategy: createOAuthAppAuth,24 auth: {25 clientId: config.get("github.clientId"),26 clientSecret: config.get("github.clientSecret"),27 },28 });29}30/**31 * @param {number} installationId32 * @returns {Promise<Octokit | null>}33 */34export async function getInstallationOctokit(installationId) {35 const appOctokit = getAppOctokit();36 const token = await (async () => {37 try {38 const { token } = await appOctokit.auth({39 type: "installation",40 installationId,41 });42 return token;43 } catch (error) {44 if (error.status === 404) {45 return null;46 }47 throw error;48 }49 })();...
Using AI Code Generation
1const argos = require('argos-ci');2(async () => {3 const octokit = await argos.getAppOctokit();4 const { data: pullRequests } = await octokit.pulls.list({5 });6 console.log(pullRequests);7})();
Using AI Code Generation
1const { getAppOctokit } = require('argos-ci-lib')2module.exports = async () => {3 const octokit = await getAppOctokit()4 const { data: repos } = await octokit.repos.listForOrg({ org: 'argos-ci' })5}6MIT © [Argos-CI](
Using AI Code Generation
1const argos = require('argos-ci');2const octokit = argos.getAppOctokit();3const owner = 'owner';4const repo = 'repo';5const pull_number = 1;6const pr = await octokit.pulls.get({ owner, repo, pull_number });7const prNumber = pr.data.number;8const prTitle = pr.data.title;9const prBody = pr.data.body;10const prAuthor = pr.data.user.login;11const prAuthorAvatar = pr.data.user.avatar_url;12const prAuthorUrl = pr.data.user.html_url;13const prUrl = pr.data.html_url;14const prState = pr.data.state;15const prCreatedAt = pr.data.created_at;16const prUpdatedAt = pr.data.updated_at;17const prClosedAt = pr.data.closed_at;18const prMergedAt = pr.data.merged_at;19const prHeadSha = pr.data.head.sha;20const prHeadRef = pr.data.head.ref;21const prHeadLabel = pr.data.head.label;22const prHeadRepoFullName = pr.data.head.repo.full_name;23const prHeadRepoUrl = pr.data.head.repo.html_url;24const prBaseSha = pr.data.base.sha;25const prBaseRef = pr.data.base.ref;26const prBaseLabel = pr.data.base.label;27const prBaseRepoFullName = pr.data.base.repo.full_name;28const prBaseRepoUrl = pr.data.base.repo.html_url;29const prCommits = pr.data.commits;30const prAdditions = pr.data.additions;31const prDeletions = pr.data.deletions;32const prChangedFiles = pr.data.changed_files;33const prReviewComments = pr.data.review_comments;34const prAssignees = pr.data.assignees;35const prAssigneesLogins = pr.data.assignees.map(assignee => assignee.login);36const prRequestedReviewers = pr.data.requested_reviewers;37const prRequestedReviewersLogins = pr.data.requested_reviewers.map(38);39const prRequestedTeams = pr.data.requested_teams;40const prRequestedTeamsSlugs = pr.data.requested_teams.map(team => team.slug);41const prLabels = pr.data.labels;42const prLabelsNames = pr.data.labels.map(label => label.name);43const prMilestone = pr.data.milestone;44const prMilestoneTitle = pr.data.milestone.title;45const prMilestoneNumber = pr.data.milestone.number;46const prMilestoneState = pr.data.milestone.state;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!