diff --git a/.github/workflows/deploy-info-comment-on-pr.yml b/.github/workflows/deploy-info-comment-on-pr.yml index fc31e2d..4582642 100644 --- a/.github/workflows/deploy-info-comment-on-pr.yml +++ b/.github/workflows/deploy-info-comment-on-pr.yml @@ -19,7 +19,11 @@ jobs: - name: Check if Deploy Workflow is Running id: check_deploy run: | - runs=$(gh run list --branch ${{ github.head_ref }} --workflow "Deploy to Cloudflare Pages" --json status --jq '.[] | select(.status == "in_progress")') + runs=$(gh run list --branch "${{ github.head_ref }}" \ + --workflow "Deploy to Cloudflare Pages" \ + --json status \ + --jq '.[] | select(.status == "in_progress")' 2>/dev/null) + if [[ -n "$runs" ]]; then echo "Deploy workflow is currently running. Exiting." echo "DEPLOY_STATUS=running" >> $GITHUB_ENV diff --git a/app/page.tsx b/app/page.tsx index 55854de..c0ee3bf 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -10,6 +10,8 @@ export default async function Home() { const session = await auth(); if (!session?.user) return null; + console.log(session); + return (
diff --git a/lib/auth.ts b/lib/auth.ts index 85c62c5..8e76153 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -3,9 +3,20 @@ import GitHub from "next-auth/providers/github"; import "next-auth/jwt"; export const { handlers, auth, signIn, signOut } = NextAuth({ - providers: [GitHub], + providers: [ + GitHub({ + authorization: { + param: { + scope: "repo read:user", + }, + }, + }), + ], callbacks: { - async jwt({ token, profile }) { + async jwt({ token, profile, account }) { + if (account) { + token.accessToken = account.access_token; + } if (profile) { const { login } = profile; token.user = { ...token.user, login }; @@ -15,6 +26,7 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ async session({ session, token }) { const { login } = token.user; session.user = { ...session.user, login }; + session.accessToken = token.accessToken; return session; }, }, @@ -24,6 +36,7 @@ declare module "next-auth" { user: { login: string; } & DefaultSession["user"]; + accessToken: string; } interface User { login: string; @@ -31,11 +44,15 @@ declare module "next-auth" { interface Profile { login: string; } + interface Account { + access_token: string; + } } declare module "next-auth/jwt" { interface JWT { user: { login: string; }; + accessToken: string; } }