Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open source #11

Merged
merged 7 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

31 changes: 28 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ jobs:
build:
runs-on: ubuntu-latest

env:
VITE_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -27,5 +24,33 @@ jobs:
- name: Install dependencies
run: npm install

- name: Lint code
run: npm run lint

- name: Build app
run: npm run build

- name: Checks Failed
if: failure()
uses: actions/github-script@v6
with:
script: |
core.setFailed("Linting or build errors detected. Please fix them and push again.")
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "⚠️ Looks like you missed something Linting or build errors detected. Please fix them and push again."
})

- name: All Checks Passed
if: success()
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Kudos! All checks passed. 🎉 Thanks for contributing to the project, one of our maintainers will review your changes soon."
})
9 changes: 3 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Deploy to GitHub Pages 🚀

on:
push:
branches:
- main
push:
branches:
- main

permissions:
contents: read
Expand All @@ -21,9 +21,6 @@ jobs:
url: ${{steps.deployment.outputs.page_url}}
runs-on: ubuntu-latest

env:
VITE_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
39 changes: 18 additions & 21 deletions src/components/StatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@ import Tooltip from "./Elements/Tooltip"
import { Chrome, Copyright, Eye, Fullscreen, GitBranch, GitFork, Github, Hash, Scale, Star } from "lucide-react"
import values from "@/values/strings.json"

type License = {
key: string,
name: string,
url: string,
}

type RepositoryData = {
stargazers_count: number,
forks_count: number,
watchers_count: number,
license: License,
full_name: string
}

function StatusBar() {
Expand All @@ -24,15 +18,14 @@ function StatusBar() {
const fetchRepositoryData = async () => {
// make fetch request with above using fetch api
// Add X-GitHub-Api-Version: 2022-11-28 header to request
const headers = new Headers()
headers.append('Accept', 'application/vnd.github.v3+json')
headers.append('X-GitHub-Api-Version', '2022-11-28')
headers.append('Authorization', `token ${import.meta.env.VITE_GITHUB_ACCESS_TOKEN}`)
const response = await fetch('https://api.github.com/repos/salman-ibrahim/codefolio', {
headers: headers
})
// const endpoint = 'https://api.github.com/repos/salman-ibrahim/codefolio'
const endpoint = 'https://api.github.com/search/repositories?q=salman-ibrahim/codefolio'
const response = await fetch(endpoint)
const data = await response.json()
setRepositoryData(data)

// Filter from all the results where item.full_name === salman-ibrahim/codefolio
const repo = data.items.filter((item: RepositoryData) => item.full_name === 'salman-ibrahim/codefolio')[0]
setRepositoryData(repo)
}

useEffect(() => {
Expand Down Expand Up @@ -111,12 +104,16 @@ function StatusBar() {
<span className="ml-1">CSS</span>
</div>

<a className="unstyled-link" href={repositoryData?.license?.url} target="_blank" rel="noreferrer">
<div className="status-item items-center">
<Scale size={12} />
<span className="ml-1">MIT</span>
</div>
</a>
{
values.links.license !== undefined
&&
<a className="unstyled-link" href={values.links.license} target="_blank" rel="noreferrer">
<div className="status-item items-center">
<Scale size={12} />
<span className="ml-1">MIT</span>
</div>
</a>
}

<a className="unstyled-link" href={values.github} target="_blank" rel="noreferrer">
<div className="status-item items-center">
Expand Down