Skip to content

Commit 9bb575d

Browse files
All Code Together
0 parents  commit 9bb575d

File tree

126 files changed

+33057
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+33057
-0
lines changed

.gitattributes

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* text eol=lf
2+
3+
# Denote all files that are truly binary and should not be modified
4+
*.ttf binary
5+
*.png binary
6+
*.webp binary
7+
*.woff binary
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Azure Static Web Apps CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, closed]
9+
branches:
10+
- main
11+
12+
jobs:
13+
build_and_deploy_job:
14+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
15+
runs-on: ubuntu-latest
16+
name: Build and Deploy Job
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: true
21+
lfs: false
22+
- name: Build And Deploy
23+
id: builddeploy
24+
uses: Azure/static-web-apps-deploy@v1
25+
with:
26+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GREEN_MUD_0FF7B9010 }}
27+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
28+
action: "upload"
29+
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
30+
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
31+
app_location: "/" # App source code path
32+
api_location: "" # Api source code path - optional
33+
output_location: "" # Built app content directory - optional
34+
###### End of Repository/Build Configurations ######
35+
36+
close_pull_request_job:
37+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
38+
runs-on: ubuntu-latest
39+
name: Close Pull Request Job
40+
steps:
41+
- name: Close Pull Request
42+
id: closepullrequest
43+
uses: Azure/static-web-apps-deploy@v1
44+
with:
45+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GREEN_MUD_0FF7B9010 }}
46+
action: "close"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Azure Static Web Apps CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, closed]
9+
branches:
10+
- main
11+
12+
jobs:
13+
build_and_deploy_job:
14+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
15+
runs-on: ubuntu-latest
16+
name: Build and Deploy Job
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: true
21+
lfs: false
22+
- name: Build And Deploy
23+
id: builddeploy
24+
uses: Azure/static-web-apps-deploy@v1
25+
with:
26+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_POLITE_OCEAN_092AD1510 }}
27+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
28+
action: "upload"
29+
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
30+
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
31+
app_location: "/" # App source code path
32+
api_location: "" # Api source code path - optional
33+
output_location: "" # Built app content directory - optional
34+
###### End of Repository/Build Configurations ######
35+
36+
close_pull_request_job:
37+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
38+
runs-on: ubuntu-latest
39+
name: Close Pull Request Job
40+
steps:
41+
- name: Close Pull Request
42+
id: closepullrequest
43+
uses: Azure/static-web-apps-deploy@v1
44+
with:
45+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_POLITE_OCEAN_092AD1510 }}
46+
action: "close"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Azure Static Web Apps CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, closed]
9+
branches:
10+
- main
11+
12+
jobs:
13+
build_and_deploy_job:
14+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
15+
runs-on: ubuntu-latest
16+
name: Build and Deploy Job
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: true
21+
lfs: false
22+
- name: Build And Deploy
23+
id: builddeploy
24+
uses: Azure/static-web-apps-deploy@v1
25+
with:
26+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_SKY_08098EB10 }}
27+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
28+
action: "upload"
29+
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
30+
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
31+
app_location: "/" # App source code path
32+
api_location: "" # Api source code path - optional
33+
output_location: "" # Built app content directory - optional
34+
###### End of Repository/Build Configurations ######
35+
36+
close_pull_request_job:
37+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
38+
runs-on: ubuntu-latest
39+
name: Close Pull Request Job
40+
steps:
41+
- name: Close Pull Request
42+
id: closepullrequest
43+
uses: Azure/static-web-apps-deploy@v1
44+
with:
45+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_SKY_08098EB10 }}
46+
action: "close"

.gitignore

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
/build
11+
12+
13+
# misc
14+
.DS_Store
15+
.env
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
#user generated content
26+
public/profile.json
27+
public/blogs.json

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
src/serviceWorker.js
2+
package-lock.json
3+
src/assets/lottie
4+

.prettierrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"trailingComma": "none",
3+
"bracketSpacing": false,
4+
"arrowParens": "avoid",
5+
"singleQuote": false,
6+
"printWidth": 80,
7+
"useTabs": false,
8+
"tabWidth": 2,
9+
"semi": true
10+
}
11+

env.example

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// README
2+
// This is only a .env example
3+
// Do not change this file, adding your GITHUB TOKEN here!
4+
// Use cp or mv (like this: cp env.example .env), then edit .env with your GITHUB TOKEN.
5+
// IMPORTANT: Don't forget to add to update your .gitignore with .env (to avoid making your key public!)
6+
7+
REACT_APP_GITHUB_TOKEN = "YOUR GITHUB TOKEN HERE"
8+
GITHUB_USERNAME = "YOUR GITHUB USERNAME HERE"
9+
// Set to true to fetch profile data from GitHub (remember to remove all components relying on GitHub data if set to false)
10+
USE_GITHUB_DATA = "true"
11+
// Set to your username in order to fetch blog data from Medium (otherwise, hardcoded values from Blogs.js are used)
12+
MEDIUM_USERNAME = "YOU MEDIUM USERNAME HERE"

fetch.js

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
fs = require("fs");
2+
const https = require("https");
3+
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+
const USE_GITHUB_DATA = process.env.USE_GITHUB_DATA;
9+
const MEDIUM_USERNAME = process.env.MEDIUM_USERNAME;
10+
11+
const ERR = {
12+
noUserName:
13+
"Github Username was found to be undefined. Please set all relevant environment variables.",
14+
requestFailed:
15+
"The request to GitHub didn't succeed. Check if GitHub token in your .env file is correct.",
16+
requestFailedMedium:
17+
"The request to Medium didn't succeed. Check if Medium username in your .env file is correct."
18+
};
19+
if (USE_GITHUB_DATA === "true") {
20+
if (GITHUB_USERNAME === undefined) {
21+
throw new Error(ERR.noUserName);
22+
}
23+
24+
console.log(`Fetching profile data for ${GITHUB_USERNAME}`);
25+
var data = JSON.stringify({
26+
query: `
27+
{
28+
user(login:"${GITHUB_USERNAME}") {
29+
name
30+
bio
31+
avatarUrl
32+
location
33+
pinnedItems(first: 6, types: [REPOSITORY]) {
34+
totalCount
35+
edges {
36+
node {
37+
... on Repository {
38+
name
39+
description
40+
forkCount
41+
stargazers {
42+
totalCount
43+
}
44+
url
45+
id
46+
diskUsage
47+
primaryLanguage {
48+
name
49+
color
50+
}
51+
}
52+
}
53+
}
54+
}
55+
}
56+
}
57+
`
58+
});
59+
const default_options = {
60+
hostname: "api.github.com",
61+
path: "/graphql",
62+
port: 443,
63+
method: "POST",
64+
headers: {
65+
Authorization: `Bearer ${GITHUB_TOKEN}`,
66+
"User-Agent": "Node"
67+
}
68+
};
69+
70+
const req = https.request(default_options, res => {
71+
let data = "";
72+
73+
console.log(`statusCode: ${res.statusCode}`);
74+
if (res.statusCode !== 200) {
75+
throw new Error(ERR.requestFailed);
76+
}
77+
78+
res.on("data", d => {
79+
data += d;
80+
});
81+
res.on("end", () => {
82+
fs.writeFile("./public/profile.json", data, function (err) {
83+
if (err) return console.log(err);
84+
console.log("saved file to public/profile.json");
85+
});
86+
});
87+
});
88+
89+
req.on("error", error => {
90+
throw error;
91+
});
92+
93+
req.write(data);
94+
req.end();
95+
}
96+
97+
if (MEDIUM_USERNAME !== undefined) {
98+
console.log(`Fetching Medium blogs data for ${MEDIUM_USERNAME}`);
99+
const options = {
100+
hostname: "api.rss2json.com",
101+
path: `/v1/api.json?rss_url=https://medium.com/feed/@${MEDIUM_USERNAME}`,
102+
port: 443,
103+
method: "GET"
104+
};
105+
106+
const req = https.request(options, res => {
107+
let mediumData = "";
108+
109+
console.log(`statusCode: ${res.statusCode}`);
110+
if (res.statusCode !== 200) {
111+
throw new Error(ERR.requestMediumFailed);
112+
}
113+
114+
res.on("data", d => {
115+
mediumData += d;
116+
});
117+
res.on("end", () => {
118+
fs.writeFile("./public/blogs.json", mediumData, function (err) {
119+
if (err) return console.log(err);
120+
console.log("saved file to public/blogs.json");
121+
});
122+
});
123+
});
124+
125+
req.on("error", error => {
126+
throw error;
127+
});
128+
129+
req.end();
130+
}

0 commit comments

Comments
 (0)