From ada553684b54e8bcf10de0d8a6f6e9c181f79a8f Mon Sep 17 00:00:00 2001 From: Martin Robledo Date: Thu, 19 Oct 2023 16:34:01 -0600 Subject: [PATCH 1/6] feat: improve github activity script --- app/routes/api/github/get-proyectActivity.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/routes/api/github/get-proyectActivity.tsx b/app/routes/api/github/get-proyectActivity.tsx index b3f3efc2..768abc7a 100644 --- a/app/routes/api/github/get-proyectActivity.tsx +++ b/app/routes/api/github/get-proyectActivity.tsx @@ -23,10 +23,11 @@ export const getActivity = async (repo: string, projectId: string) => { const repoActivity = await octokit.request(`GET /repos/${owner}/${repoUrlClean}/events`, { owner, repo, - }).catch((e) => { throw(e)}); + }); - - if(repoActivity.data.length){ + if(repoActivity.status != 404){ + // eslint-disable-next-line no-console + console.log( repo , repoUrlClean , repoActivity.status, repoActivity.headers["x-ratelimit-remaining"], repoActivity.data.length); repoActivity.data?.forEach( (activity: { id: string; type: string; created_at: string; actor: { display_login: string; avatar_url: string; }; }) => { saveActivity(activity.id , activity.type?.replace(/([a-z0-9])([A-Z])/g, '$1 $2') as string, //this is for separe the string with camel case into pieces @@ -38,7 +39,7 @@ export const getActivity = async (repo: string, projectId: string) => { }catch(e){ - console.error(e); + console.error('no existe la pagina', repoUrlClean); } }else{ From 8d697004128cb148cdcdfb289435db6222d4f012 Mon Sep 17 00:00:00 2001 From: Martin Robledo Date: Mon, 23 Oct 2023 11:49:45 -0600 Subject: [PATCH 2/6] changed error message --- app/routes/api/github/get-proyectActivity.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/api/github/get-proyectActivity.tsx b/app/routes/api/github/get-proyectActivity.tsx index 768abc7a..f828e2c8 100644 --- a/app/routes/api/github/get-proyectActivity.tsx +++ b/app/routes/api/github/get-proyectActivity.tsx @@ -39,7 +39,7 @@ export const getActivity = async (repo: string, projectId: string) => { }catch(e){ - console.error('no existe la pagina', repoUrlClean); + console.error('the repo url doesnt exit', repoUrlClean); } }else{ From 5888db2e5db7e7997227798d76fe1807b6b57873 Mon Sep 17 00:00:00 2001 From: Martin Robledo Date: Mon, 23 Oct 2023 12:55:42 -0600 Subject: [PATCH 3/6] debbuging script --- app/routes/api/github/get-proyectActivity.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/routes/api/github/get-proyectActivity.tsx b/app/routes/api/github/get-proyectActivity.tsx index b3f3efc2..00376d31 100644 --- a/app/routes/api/github/get-proyectActivity.tsx +++ b/app/routes/api/github/get-proyectActivity.tsx @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { Octokit } from "@octokit/core"; import { env } from "process"; import { saveActivity } from "../../../models/githubactivity.server"; @@ -23,10 +24,14 @@ export const getActivity = async (repo: string, projectId: string) => { const repoActivity = await octokit.request(`GET /repos/${owner}/${repoUrlClean}/events`, { owner, repo, - }).catch((e) => { throw(e)}); + }); + console.log('limit ', repoActivity.headers["x-ratelimit-limit"]); + console.log('ratelimit-remaining ', repoActivity.headers["x-ratelimit-remaining"]); - if(repoActivity.data.length){ + if(repoActivity.status != 404){ + // eslint-disable-next-line no-console + console.log( repo , repoUrlClean , repoActivity.status, repoActivity.headers["x-ratelimit-limit"], repoActivity.data.length); repoActivity.data?.forEach( (activity: { id: string; type: string; created_at: string; actor: { display_login: string; avatar_url: string; }; }) => { saveActivity(activity.id , activity.type?.replace(/([a-z0-9])([A-Z])/g, '$1 $2') as string, //this is for separe the string with camel case into pieces @@ -38,7 +43,7 @@ export const getActivity = async (repo: string, projectId: string) => { }catch(e){ - console.error(e); + console.error('the repo url doesnt exit', repoUrlClean); } }else{ From 9465c21e4554b933320f29da04bce020b32d56ea Mon Sep 17 00:00:00 2001 From: Martin Robledo Date: Mon, 23 Oct 2023 15:58:39 -0600 Subject: [PATCH 4/6] feat: added missing config in deploy file --- .github/workflows/deploy.yml | 4 ++++ app/routes/api/github/get-proyectActivity.tsx | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 45ec34ea..94332faa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -199,6 +199,7 @@ jobs: AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }} GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + GITHUB_KEY: ${{ secrets.GITHUB_KEY }} with: timeout: 60s command_timeout: 30m @@ -225,6 +226,7 @@ jobs: echo AUTH0_DOMAIN="$AUTH0_DOMAIN" >> .env echo AUTH0_CLIENT_SECRET="$AUTH0_CLIENT_SECRET" >> .env echo GOOGLE_APPLICATION_CREDENTIALS="$GOOGLE_APPLICATION_CREDENTIALS" >> .env + echo GITHUB_KEY="$GITHUB_KEY" >> .env echo "*** Step: *** npm ci and build" npm ci # install @@ -316,6 +318,7 @@ jobs: AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }} GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + GITHUB_KEY: ${{ secrets.GITHUB_KEY }} with: timeout: 60s command_timeout: 30m @@ -343,6 +346,7 @@ jobs: echo AUTH0_DOMAIN="$AUTH0_DOMAIN" >> .env echo AUTH0_CLIENT_SECRET="$AUTH0_CLIENT_SECRET" >> .env echo GOOGLE_APPLICATION_CREDENTIALS="$GOOGLE_APPLICATION_CREDENTIALS" >> .env + echo GITHUB_KEY="$GITHUB_KEY" >> .env echo "*** Step: *** npm ci and build" npm ci # install diff --git a/app/routes/api/github/get-proyectActivity.tsx b/app/routes/api/github/get-proyectActivity.tsx index 7c19d0c1..d145ba2c 100644 --- a/app/routes/api/github/get-proyectActivity.tsx +++ b/app/routes/api/github/get-proyectActivity.tsx @@ -23,15 +23,14 @@ export const getActivity = async (repo: string, projectId: string) => { try{ const repoActivity = await octokit.request(`GET /repos/${owner}/${repoUrlClean}/events`, { owner, - repo, + repoUrlClean, }); - console.log('limit ', repoActivity.headers["x-ratelimit-limit"]); console.log('ratelimit-remaining ', repoActivity.headers["x-ratelimit-remaining"]); if(repoActivity.status != 404){ // eslint-disable-next-line no-console - console.log( repo , repoUrlClean , repoActivity.status, repoActivity.headers["x-ratelimit-limit"], repoActivity.headers["x-ratelimit-remaining"],repoActivity.data.length); + console.log( repoUrlClean , repoUrlClean , repoActivity.status, repoActivity.headers["x-ratelimit-limit"], repoActivity.headers["x-ratelimit-remaining"],repoActivity.data.length); repoActivity.data?.forEach( (activity: { id: string; type: string; created_at: string; actor: { display_login: string; avatar_url: string; }; }) => { saveActivity(activity.id , activity.type?.replace(/([a-z0-9])([A-Z])/g, '$1 $2') as string, //this is for separe the string with camel case into pieces From cae71282906e0b36b334ace2b9dc76858934f304 Mon Sep 17 00:00:00 2001 From: Martin Robledo Date: Mon, 23 Oct 2023 15:59:56 -0600 Subject: [PATCH 5/6] feat: github key to envs param --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 94332faa..f484f24f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -203,7 +203,7 @@ jobs: with: timeout: 60s command_timeout: 30m - envs: DB_URL,DATABASE_URL,SESSION_SECRET,BASE_URL,AUTH0_CLIENT_ID,AUTH0_DOMAIN,AUTH0_CLIENT_SECRET,GOOGLE_APPLICATION_CREDENTIALS + envs: DB_URL,DATABASE_URL,SESSION_SECRET,BASE_URL,AUTH0_CLIENT_ID,AUTH0_DOMAIN,AUTH0_CLIENT_SECRET,GOOGLE_APPLICATION_CREDENTIALS,GITHUB_KEY host: ${{ secrets.LIGHTSAIL_IP }} username: ${{ secrets.LIGHTSAIL_USER }} key: ${{ secrets.SSH_PRIVATE_KEY }} @@ -322,7 +322,7 @@ jobs: with: timeout: 60s command_timeout: 30m - envs: DB_URL,DATABASE_URL,SESSION_SECRET,BASE_URL,AUTH0_CLIENT_ID,AUTH0_DOMAIN,AUTH0_CLIENT_SECRET,GOOGLE_APPLICATION_CREDENTIALS + envs: DB_URL,DATABASE_URL,SESSION_SECRET,BASE_URL,AUTH0_CLIENT_ID,AUTH0_DOMAIN,AUTH0_CLIENT_SECRET,GOOGLE_APPLICATION_CREDENTIALS,GITHUB_KEY host: ${{ secrets.LIGHTSAIL_IP }} username: ${{ secrets.LIGHTSAIL_USER }} key: ${{ secrets.SSH_PRIVATE_KEY }} From 1f5d01e08c3ea54f436e76d259faa821c218881f Mon Sep 17 00:00:00 2001 From: Martin Robledo Date: Mon, 23 Oct 2023 16:26:44 -0600 Subject: [PATCH 6/6] feat: added correct name of github variable in decrets --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f484f24f..49073872 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -199,7 +199,7 @@ jobs: AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }} GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} - GITHUB_KEY: ${{ secrets.GITHUB_KEY }} + GITHUB_KEY: ${{ secrets.API_GITHUB_KEY }} with: timeout: 60s command_timeout: 30m @@ -318,7 +318,7 @@ jobs: AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }} GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} - GITHUB_KEY: ${{ secrets.GITHUB_KEY }} + GITHUB_KEY: ${{ secrets.API_GITHUB_KEY }} with: timeout: 60s command_timeout: 30m