File tree Expand file tree Collapse file tree 4 files changed +56
-5
lines changed Expand file tree Collapse file tree 4 files changed +56
-5
lines changed Original file line number Diff line number Diff 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-->
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ if(process.env.ACCESS_TOKEN === undefined){
88
99import { Octokit } from "@octokit/rest" ;
1010import { readFileSync , writeFileSync } from "fs" ;
11+ import { updateWorkflowNumber } from "./updateWorkflowNumber.js" ;
1112import { READMEFILE_PATH } from "./config.js" ;
1213
1314const 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+ } )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ dotenv.config();
33
44import axios from "axios" ;
55import { readFileSync , writeFileSync } from "fs" ;
6+ import { updateWorkflowNumber } from "./updateWorkflowNumber.js" ;
67import { BlogsResponseSchema , READMEFILE_PATH } from "./config.js" ;
78
89const 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+ } ) ;
Original file line number Diff line number Diff line change 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+ / T h e r e h a v e b e e n \* \* \d + \* \* w o r k f l o w r u n s s o f a r \. / ,
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+ }
You can’t perform that action at this time.
0 commit comments