diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000000..f690de2c03 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,48 @@ +name: Vercel Preview Deployment +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VTEX_GITHUB_BOT_TOKEN: ${{ secrets.DOC_GH_TOKEN }} +on: + push: + branches-ignore: + - main + +jobs: + Deploy-Preview: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + token: ${{ secrets.VTEX_GITHUB_BOT_TOKEN }} + fetch-depth: 0 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.4.0 + + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Install Vercel CLI + run: npm install vercel -g + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} diff --git a/packages/docs/package.json b/packages/docs/package.json index e205d3514c..357a892888 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,51 +1,47 @@ { - "name": "@shoreline/docs", - "version": "1.0.7", - "private": true, - "type": "module", - "scripts": { - "dev": "npm run gen:examples && npm run gen:props && next dev", - "build-docs": "npm --prefix ../../ run build && npm run gen:contributors && npm run gen:examples && npm run gen:props && next build", - "start": "next start", - "gen:examples": "node ./scripts/build-examples.mjs", - "gen:props": "node ./scripts/build-props.mjs", - "gen:contributors": "node ./scripts/build-contributors.mjs" - }, - "devDependencies": { - "@types/fs-extra": "11.0.4", - "@types/node": "20.14.9" - }, - "dependencies": { - "@next/third-parties": "^15.0.0", - "@octokit/graphql": "^8.1.1", - "@sentry/nextjs": "^8.35.0", - "@tanstack/react-table": "8.17.3", - "@vtex/shoreline": "workspace:*", - "@vtex/shoreline-ts-table": "workspace:*", - "@vtex/shoreline-utils": "workspace:*", - "fs-extra": "11.2.0", - "google": "link:@next/third-parties/google", - "next": "^15.0.0", - "nextra": "^3.0.15", - "nextra-theme-docs": "^3.0.15", - "prettier": "^3.3.3", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "react-markdown": "^9.0.1", - "shiki": "^1.22.0", - "swr": "^2.2.5", - "ts-morph": "^24.0.0" - }, - "browserslist": { - "production": [ - ">0.5%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } + "name": "@shoreline/docs", + "version": "1.0.7", + "private": true, + "type": "module", + "scripts": { + "dev": "npm run gen:examples && npm run gen:props && next dev", + "build-docs": "npm --prefix ../../ run build && npm run gen:contributors && npm run gen:examples && npm run gen:props && next build", + "start": "next start", + "gen:examples": "node ./scripts/build-examples.mjs", + "gen:props": "node ./scripts/build-props.mjs", + "gen:contributors": "node ./scripts/build-contributors.mjs" + }, + "devDependencies": { + "@types/fs-extra": "11.0.4", + "@types/node": "20.14.9" + }, + "dependencies": { + "@next/third-parties": "^15.0.0", + "@octokit/graphql": "^8.1.1", + "@sentry/nextjs": "^8.35.0", + "@tanstack/react-table": "8.17.3", + "@vtex/shoreline": "workspace:*", + "@vtex/shoreline-ts-table": "workspace:*", + "@vtex/shoreline-utils": "workspace:*", + "fs-extra": "11.2.0", + "google": "link:@next/third-parties/google", + "next": "^15.0.0", + "nextra": "^3.0.15", + "nextra-theme-docs": "^3.0.15", + "prettier": "^3.3.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-markdown": "^9.0.1", + "shiki": "^1.22.0", + "swr": "^2.2.5", + "ts-morph": "^24.0.0" + }, + "browserslist": { + "production": [">0.5%", "not dead", "not op_mini all"], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } } diff --git a/packages/docs/scripts/build-contributors.mjs b/packages/docs/scripts/build-contributors.mjs index 78044c8e49..ea8e96f157 100644 --- a/packages/docs/scripts/build-contributors.mjs +++ b/packages/docs/scripts/build-contributors.mjs @@ -14,6 +14,8 @@ const REPO_NAME = 'shoreline' const token = process.env.VTEX_GITHUB_BOT_TOKEN const startDate = new Date('2024-01-01T00:00:00Z').toISOString() +console.log(`${!token ? 'Invalid' : 'Valid'} Github token!`) + const graphqlWithAuth = graphql.defaults({ headers: { authorization: `token ${token}`, @@ -339,7 +341,24 @@ export interface Contributor { export const contributors: Contributor[] = ${JSON.stringify(stats)} export function getContributor(username: string) { - return contributors.find((contributor) => contributor.username === username) + const emptyContributor = { + username: "", + image: "", + stats: { + issues: 0, + assigns: 0, + comments: 0, + pulls: 0, + reviews: 0, + merged: 0, + rate: 0, + }, + }; + + return ( + contributors.find((contributor) => contributor.username === username) ?? + emptyContributor + ); } const maintainers = [