Skip to content

Commit f194065

Browse files
Merge branch 'master' of github.com:BharatKammakatla/Developer-Portfolio
2 parents 8e8ed9d + 21d0361 commit f194065

File tree

14 files changed

+307
-430
lines changed

14 files changed

+307
-430
lines changed

.github/workflows/node.js.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: Build and Deploy
22
env:
33
CI: false
4-
REACT_APP_GITHUB_TOKEN: ${{ secrets.OPEN_SOURCE_TOKEN }}
4+
GITHUB_USERNAME: ${{ github.repository_owner }}
5+
REACT_APP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56
on:
67
push:
78
branches:
89
- master
10+
schedule:
11+
- cron: "0 12 * * 1"
912
jobs:
1013
build-and-deploy:
1114
runs-on: ubuntu-latest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222
npm-debug.log*
2323
yarn-debug.log*
2424
yarn-error.log*
25+
26+
#user generated content
27+
public/profile.json

fetch.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
var fs = require("fs");
2+
const https = require("https");
3+
var process = require("process");
4+
require("dotenv").config();
5+
6+
const GITHUB_TOKEN = process.env.REACT_APP_GITHUB_TOKEN;
7+
const GITHUB_USERNAME = process.env.GITHUB_USERNAME;
8+
9+
if (GITHUB_USERNAME === undefined) {
10+
throw "Github Username was found to be undefined. Please set an Environment variable.";
11+
}
12+
13+
console.log(`fetching profile for ${GITHUB_USERNAME}`);
14+
var data = JSON.stringify({
15+
query: `
16+
{
17+
user(login:"${GITHUB_USERNAME}") {
18+
name
19+
bio
20+
isHireable
21+
avatarUrl
22+
location
23+
pinnedItems(first: 6, types: [REPOSITORY]) {
24+
totalCount
25+
edges {
26+
node {
27+
... on Repository {
28+
name
29+
description
30+
forkCount
31+
stargazers {
32+
totalCount
33+
}
34+
url
35+
id
36+
diskUsage
37+
primaryLanguage {
38+
name
39+
color
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
`,
48+
});
49+
const default_options = {
50+
hostname: "api.github.com",
51+
path: "/graphql",
52+
port: 443,
53+
method: "POST",
54+
headers: {
55+
Authorization: `Bearer ${GITHUB_TOKEN}`,
56+
"User-Agent": "Node",
57+
},
58+
};
59+
60+
const req = https.request(default_options, (res) => {
61+
let data = "";
62+
console.log(`statusCode: ${res.statusCode}`);
63+
if (res.statusCode != 200) {
64+
throw "The request to Github didn't suceed. Maybe check Github Token?";
65+
}
66+
67+
res.on("data", (d) => {
68+
data += d;
69+
});
70+
res.on("end", () => {
71+
fs.writeFile("./public/profile.json", data, function (err) {
72+
if (err) return console.log(err);
73+
console.log("saved file to public/profile.json");
74+
});
75+
});
76+
});
77+
78+
req.on("error", (error) => {
79+
throw error;
80+
});
81+
82+
req.write(data);
83+
req.end();

0 commit comments

Comments
 (0)