File tree Expand file tree Collapse file tree 5 files changed +66
-9
lines changed Expand file tree Collapse file tree 5 files changed +66
-9
lines changed Original file line number Diff line number Diff line change 1212 - uses : actions/checkout@v4
1313 - name : Update post list
1414 run : |
15- cd scripts && npm install && npm run get:posts
15+ cd scripts && npm install && ACCESS_TOKEN=${{ secrets.ACCESS_TOKEN }} npm run get:posts
1616 - name : Commit changes
1717 run : |
1818 git config --local user.email "github-actions[bot]@users.noreply.github.com"
Original file line number Diff line number Diff line change @@ -100,6 +100,17 @@ My name is Pulkit. I'm a undergraduate from 🇮🇳
100100
101101---
102102
103+ ### :bar_chart : Coding time in the last month
104+
105+ <picture >
106+ <source media="(prefers-color-scheme: dark)" srcset="https://wakatime.com/share/@pulkitxm/b09efaa2-860c-4ed4-afbe-4a645828d6fe.svg">
107+ <img src="https://wakatime.com/share/@pulkitxm/b09efaa2-860c-4ed4-afbe-4a645828d6fe.svg" width="100%" height="auto" style="max-height: 400px; object-fit: contain;">
108+ </picture >
109+
110+ <br /><br />
111+
112+ ---
113+
103114### Let's Connect
104115
105116- [ LinkedIn] ( https://www.linkedin.com/in/pulkitxm )
@@ -108,9 +119,6 @@ My name is Pulkit. I'm a undergraduate from 🇮🇳
108119
109120---
110121
111- ### :bar_chart : [ Coding time in the last month] ( https://wakatime.com/@pulkitxm )
112-
113- <picture >
114- <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">
116- </picture >
122+ <!-- START_SECTION:blog-posts-->
123+ * Note: All the data displayed above is updated automatically via GitHub Actions. There have been ** 3** workflow runs so far.*
124+ <!-- 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