Skip to content

Commit

Permalink
Merge pull request #11 from salman-ibrahim/open-source
Browse files Browse the repository at this point in the history
Open source
  • Loading branch information
salman-ibrahim authored Nov 21, 2023
2 parents a18a423 + 487888e commit be8e07d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 31 deletions.
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

0 comments on commit be8e07d

Please sign in to comment.