Skip to content

Commit eb5de6d

Browse files
authored
Merge pull request #12 from MikAoJk/vercel
chore: deploy to vercel
2 parents cf6325b + 1e1e556 commit eb5de6d

File tree

5 files changed

+57
-47
lines changed

5 files changed

+57
-47
lines changed

.github/workflows/main.yml

+13-20
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,24 @@ concurrency:
1111
cancel-in-progress: false
1212

1313
jobs:
14-
build:
15-
name: build
14+
build-deploy:
15+
name: build-deploy
1616
runs-on: ubuntu-latest
1717
env:
1818
NEXT_PUBLIC_BASE_PATH: /norwegian-public-organizations
19+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
20+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1922
steps:
2023
- name: Checkout
2124
uses: actions/checkout@v4
2225
- name: setup bun
2326
uses: oven-sh/setup-bun@v1
24-
- name: Install packages
25-
run: bun install
26-
- name: Build
27-
run: bun run build
28-
- name: Upload artifact
29-
uses: actions/upload-pages-artifact@v3
30-
with:
31-
path: ./out
32-
deploy:
33-
environment:
34-
name: github-pages
35-
url: ${{ steps.deployment.outputs.page_url }}
36-
runs-on: ubuntu-latest
37-
needs: build
38-
steps:
39-
- name: Deploy to GitHub Pages
40-
id: deployment
41-
uses: actions/deploy-pages@v4
27+
- name: Install Vercel CLI
28+
run: bun install --global vercel@latest
29+
- name: Pull Vercel Environment Information
30+
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
31+
- name: Build Project Artifacts
32+
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
33+
- name: Deploy Project Artifacts to Vercel
34+
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ Install deps:
2020
bun run build
2121
```
2222

23+
Environment variable:
24+
Need to set an environment variable
25+
GH_TOKEN to your GitHub token
26+
```bash
27+
.bashrc example:
28+
``` shell bash
29+
export GH_TOKEN='supersecretkey'
30+
```
31+
2332
First, run the development server:
2433
```bash
2534
bun run dev
@@ -28,7 +37,7 @@ bun run dev
2837
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
2938

3039
## Deployed to GitHub pages
31-
The application is live at: https://mikaojk.github.io/norwegian-public-organizations
40+
The application is live at: https://norwegian-public-organizations.vercel.app/norwegian-public-organizations
3241

3342
## Organization is missing!!
3443
Follow the guide in the: [CONTRIBUTING.md](CONTRIBUTING.md)

next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const nextConfig = {
66
loader: 'akamai',
77
path: '/'
88
},
9-
output: 'export'
9+
output: 'standalone'
1010
}
1111

1212
module.exports = nextConfig

src/app/api/github.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use server';
2+
3+
import {Octokit} from "@octokit/core";
4+
import {paginateRest} from "@octokit/plugin-paginate-rest";
5+
import {retry} from "@octokit/plugin-retry";
6+
7+
8+
async function getNumberOfPublicRepos(owner: string): Promise<number> {
9+
10+
const octokitplugin = Octokit.plugin(paginateRest, retry).defaults({
11+
userAgent: "norwegian-public-organizations",
12+
auth: process.env.GH_TOKEN
13+
});
14+
15+
const myOctokit = new octokitplugin()
16+
17+
try {
18+
const repos = await myOctokit.request(`GET /orgs/${owner}`, {
19+
headers: {
20+
'X-GitHub-Api-Version': '2022-11-28'
21+
}
22+
})
23+
24+
return repos.data.public_repos
25+
} catch (e) {
26+
console.log(e)
27+
return 0
28+
}
29+
}
30+
31+
export default getNumberOfPublicRepos
32+

src/components/OrganizationsOnGithub.tsx

+1-25
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import React, {useEffect, useState} from 'react';
44
import organizations from "./data/organizations.json";
5-
import {Octokit} from "@octokit/core";
6-
import {paginateRest} from "@octokit/plugin-paginate-rest";
7-
import {retry} from "@octokit/plugin-retry";
5+
import getNumberOfPublicRepos from "../app/api/github";
86

97
export interface OrganizationsJson {
108
id: number;
@@ -86,25 +84,3 @@ export const OrganizationsOnGithub = () => {
8684
}
8785

8886

89-
async function getNumberOfPublicRepos(owner: string): Promise<number> {
90-
const octokitplugin = Octokit.plugin(paginateRest, retry).defaults({
91-
userAgent: "norwegian-public-organizations",
92-
/// auth: 'mysupersecrettoken'
93-
});
94-
95-
const myOctokit = new octokitplugin()
96-
97-
try {
98-
const repos = await myOctokit.request(`GET /orgs/${owner}`, {
99-
headers: {
100-
'X-GitHub-Api-Version': '2022-11-28'
101-
}
102-
})
103-
104-
return repos.data.public_repos
105-
} catch (e) {
106-
console.log(e)
107-
return 0
108-
}
109-
}
110-

0 commit comments

Comments
 (0)