Skip to content

Commit 4810db6

Browse files
committed
feat: update no. of workflows
1 parent c4a1a41 commit 4810db6

File tree

4 files changed

+56
-5
lines changed

4 files changed

+56
-5
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,15 @@ My name is Pulkit. I'm a undergraduate from 🇮🇳
108108

109109
---
110110

111-
### :bar_chart: [Coding time in the last month](https://wakatime.com/@pulkitxm)
111+
### :bar_chart: Coding time in the last month
112112

113113
<picture>
114114
<source media="(prefers-color-scheme: dark)" srcset="https://wakatime.com/share/@pulkitxm/b09efaa2-860c-4ed4-afbe-4a645828d6fe.svg">
115-
<img align="right" width="100%" src="https://wakatime.com/share/@pulkitxm/b09efaa2-860c-4ed4-afbe-4a645828d6fe.svg">
115+
<img src="https://wakatime.com/share/@pulkitxm/b09efaa2-860c-4ed4-afbe-4a645828d6fe.svg" width="100%" height="auto" style="max-height: 400px; object-fit: contain;">
116116
</picture>
117117

118+
<br/><br/>
119+
118120
<!--START_SECTION:blog-posts-->
119-
*Note: All the data displayed above is updated automatically via GitHub Actions. There have been **10** workflow runs so far.*
121+
*Note: All the data displayed above is updated automatically via GitHub Actions. There have been **3** workflow runs so far.*
120122
<!--END_SECTION:blog-posts-->

scripts/src/fetchFollowers.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if(process.env.ACCESS_TOKEN === undefined){
88

99
import { Octokit } from "@octokit/rest";
1010
import { readFileSync, writeFileSync } from "fs";
11+
import { updateWorkflowNumber } from "./updateWorkflowNumber.js";
1112
import { READMEFILE_PATH } from "./config.js";
1213

1314
const octokit = new Octokit({
@@ -65,4 +66,6 @@ async function main() {
6566
writeFileSync(READMEFILE_PATH, readme);
6667
}
6768

68-
main();
69+
main().then(async()=>{
70+
await updateWorkflowNumber()
71+
})

scripts/src/fetchLatestBlogPosts.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dotenv.config();
33

44
import axios from "axios";
55
import { readFileSync, writeFileSync } from "fs";
6+
import { updateWorkflowNumber } from "./updateWorkflowNumber.js";
67
import { BlogsResponseSchema, READMEFILE_PATH } from "./config.js";
78

89
const fetchLatestBlogs = async () => {
@@ -68,4 +69,6 @@ async function main() {
6869
writeFileSync(READMEFILE_PATH, readme);
6970
}
7071

71-
main();
72+
main().then(async () => {
73+
await updateWorkflowNumber();
74+
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import dotenv from "dotenv";
2+
dotenv.config();
3+
4+
if (process.env.ACCESS_TOKEN === undefined) {
5+
console.error("Please provide ACCESS_TOKEN in .env file");
6+
process.exit(1);
7+
}
8+
9+
import { Octokit } from "@octokit/rest";
10+
import { readFileSync, writeFileSync } from "fs";
11+
import { READMEFILE_PATH } from "./config.js";
12+
13+
const octokit = new Octokit({
14+
auth: process.env.ACCESS_TOKEN,
15+
});
16+
17+
const getWorflowCount = async () => {
18+
const username = "pulkitxm";
19+
const repoName = username;
20+
try {
21+
const response = await octokit.actions.listWorkflowRunsForRepo({
22+
owner: username,
23+
repo: repoName,
24+
});
25+
return response.data.total_count;
26+
} catch (error) {
27+
console.error(error.message);
28+
return 0;
29+
}
30+
};
31+
32+
export async function updateWorkflowNumber() {
33+
const workflowCount = await getWorflowCount();
34+
const readmeContent = readFileSync(READMEFILE_PATH, "utf-8");
35+
36+
const updatedContent = readmeContent.replace(
37+
/There have been \*\*\d+\*\* workflow runs so far\./,
38+
`There have been **${workflowCount}** workflow runs so far.`
39+
);
40+
41+
writeFileSync(READMEFILE_PATH, updatedContent, "utf-8");
42+
console.log("README file updated with the latest workflow count.");
43+
}

0 commit comments

Comments
 (0)