Skip to content

Commit

Permalink
Add: Api request from workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham-Patel07 committed Jul 20, 2024
1 parent dc95596 commit 57fb6a7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 55 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/authenticat.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Create issue on commit

on: [ push ]

jobs:
create_issue:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Create issue using REST API
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/issues \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"title": "Automated issue for commit: ${{ github.sha }}",
"body": "This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n The commit hash was: _${{ github.sha }}_."
}' \
--fail
36 changes: 0 additions & 36 deletions pages/about/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,42 +103,6 @@ import CountUp from "react-countup";

const About = () => {
const [index, setIndex] = useState(0);
const [commits, setCommits] = useState(0);
console.log("APICalling")
useEffect(() => {
const fetchCommits = async () => {
try {
const username = 'Shubham-Patel07';
const token = process.env.REACT_APP_GITHUB_TOKEN; // Use the token from environment variables
console.log("Token:", token);
const headers = { Authorization: `token ${token}` };

const repos = await axios.get(`https://api.github.com/users/${username}/repos`, { headers });
let totalCommits = 0;

for (const repo of repos.data) {
if (repo.size > 0) { // Check if the repository is non-empty
try {
const commitsData = await axios.get(`https://api.github.com/repos/${username}/${repo.name}/commits`, { headers });
totalCommits += commitsData.data.length;
} catch (error) {
if (error.response && error.response.status === 409) {
console.warn(`Repository ${repo.name} is empty.`);
} else {
throw error;
}
}
}
}
console.log(totalCommits)
setCommits(totalCommits);
} catch (error) {
console.error("Error fetching commit data:", error.message);
}
};

fetchCommits();
}, []);
return (
<div className="h-full bg-primary/30 py-32 text-center xl:text-left">
<Circles />
Expand Down

0 comments on commit 57fb6a7

Please sign in to comment.