Skip to content

Commit

Permalink
feat: github action for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeherby committed Feb 4, 2024
1 parent 568fe95 commit 86af5a4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.js CI
name: Pull Request

on: [pull_request]

Expand All @@ -9,9 +9,9 @@ jobs:
matrix:
project: [ui, server]
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
Expand Down
4 changes: 4 additions & 0 deletions server/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"deprecation",
"unicorn"
],
"ignorePatterns": [
"node_modules/",
"dist/"
],
"rules": {
"unicorn/filename-case": "error",
"indent": [
Expand Down
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "langtrace-ingest",
"name": "langtrace-server",
"version": "1.0.0",
"main": "src/ingestor_server.ts",
"main": "src/ingestor-server.ts",
"scripts": {
"start:langtrace": "ts-node src/langtrace-server.ts",
"start:ingestor": "ts-node src/ingest-server.ts",
Expand Down
5 changes: 5 additions & 0 deletions ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"plugins": [
"unicorn"
],
"ignorePatterns": [
"node_modules/",
".next/",
"dist/"
],
"rules": {
"unicorn/filename-case": [
"error",
Expand Down
15 changes: 10 additions & 5 deletions ui/src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import NextAuth, { NextAuthOptions } from 'next-auth';
import NextAuth, { NextAuthOptions, Profile } from 'next-auth';
import GithubProvider from 'next-auth/providers/github';
import { NextApiRequest, NextApiResponse } from 'next';

const enableAuth = process.env.NEXTAUTH_ENABLE === 'true';

interface GitHubProfile extends Profile {
login: string;

}

const options = {
providers: [
GithubProvider({
clientId: process.env.NEXTAUTH_GITHUB_ID,
clientSecret: process.env.NEXTAUTH_GITHUB_SECRET,
clientId: process.env.NEXTAUTH_GITHUB_ID!,
clientSecret: process.env.NEXTAUTH_GITHUB_SECRET!,
authorization: {
params: {
scope: 'read:user,user:email,read:org',
Expand All @@ -20,10 +25,10 @@ const options = {
async signIn({ account, profile }) {
if (account?.provider === 'github' &&
(process.env.NEXTAUTH_GITHUB_ORGANISATION ?? '').trim() !== '') {

const orgName = process.env.NEXTAUTH_GITHUB_ORGANISATION;
const token = account.access_token;
const url = `https://api.github.com/orgs/${orgName}/members/${profile?.login}`;
const url =
`https://api.github.com/orgs/${orgName}/members/${(profile as GitHubProfile).login}`;
const response = await fetch(url, {
headers: {
Authorization: `token ${token}`,
Expand Down

0 comments on commit 86af5a4

Please sign in to comment.