Skip to content

Commit

Permalink
update recent-contribution once a week
Browse files Browse the repository at this point in the history
  • Loading branch information
yshrsmz committed Dec 14, 2024
1 parent 89e4792 commit 3b26680
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/recent-contributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: fetch and save recent contributions
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
- cron: '0 0 * * 0'

concurrency:
group: fetch-and-save-recent-contributions
Expand Down
13 changes: 12 additions & 1 deletion packages/blog/.vitepress/theme/components/VPContributions.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<script setup lang="ts">
import { computed } from 'vue'
import { data } from '../contributions.data.js'
import VPPullRequest from './VPPullRequest.vue';
const datetime = computed(() => {
const date = new Date(data.updated_at);
return date.toISOString();
})
const updatedAt = computed(() => {
const date = new Date(data.updated_at);
return date.toLocaleString('en-US', { dateStyle: 'medium', timeStyle: 'short' });
})
</script>

<template>
Expand All @@ -16,6 +26,7 @@ import VPPullRequest from './VPPullRequest.vue';
@{{ data.user.username }}'s recent pull requests on GitHub.
</a>
</p>
<p class=" text-sm text-gray-500 dark:text-gray-400">Last update: <time :datetime="datetime">{{ updatedAt }}</time></p>
<div class="flex items-center align-center text-center flex-row mt-2 sm:mt-6 mb-6 sm:mb-10 w-1/2 mx-auto animate-pulse">
<div class="flex border-gray-200 dark:border-gray-800 w-full border-t border-solid"></div>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/blog/.vitepress/theme/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface PullRequest {
}

export interface Contributions {
updated_at: number
user: User
prs: PullRequest[]
}
3 changes: 2 additions & 1 deletion packages/blog/data/recent-contributions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"updated_at": 1734049860000,
"user": {
"name": "Yasuhiro SHIMIZU",
"username": "yshrsmz",
Expand Down Expand Up @@ -496,4 +497,4 @@
"stars": 413
}
]
}
}
3 changes: 2 additions & 1 deletion packages/recent-contributions/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function fetchMe(octokit: Octokit): Promise<User> {
}
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const REPO_CACHE = new Map<string, any>()

export async function fetchRepo(octokit: Octokit, owner: string, name: string) {
Expand Down Expand Up @@ -64,5 +65,5 @@ export async function fetchContributions(
})
}

return { user, prs }
return { updated_at: Date.now(), user, prs }
}
2 changes: 1 addition & 1 deletion packages/recent-contributions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Octokit, App } from 'octokit'
import { Octokit } from 'octokit'
import { fetchContributions, fetchMe } from './github'
import fs from 'node:fs/promises'

Expand Down
1 change: 1 addition & 0 deletions packages/recent-contributions/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface PullRequest {
}

export interface Contributions {
updated_at: number
user: User
prs: PullRequest[]
}
6 changes: 3 additions & 3 deletions packages/recent-contributions/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {defineConfig} from 'vitest/config'
import { defineConfig } from 'vitest/config'

export default defineConfig({
envDir: '.',
test: {
globals: false
}
globals: false,
},
})

0 comments on commit 3b26680

Please sign in to comment.