Skip to content

Commit

Permalink
Calculate 7 day score (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
vilaca authored Mar 6, 2024
1 parent b2658d0 commit 94da679
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 4 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/fetch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,39 @@ jobs:
cron:
runs-on: ubuntu-latest
steps:

- name: Git clone
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Build

- name: Fetch
env:
PAT: ${{ secrets.PAT }}
shell: bash
run: ./scripts/fetch.sh

- name: Score
env:
PAT: ${{ secrets.PAT }}
shell: bash
run: |
today=$(./scripts/utils/today.sh)
sevenDaysAgo=$(./scripts/utils/sevenDaysAgo.sh)
echo $today
echo $sevenDaysAgo
./scripts/score.sh data/$today data/$sevenDaysAgo
sort -nr score-output > data/"$today"-score
rm score-output
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: GitHub Commit & Push
uses: actions-js/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.extract_branch.outputs.branch }}

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ curl https://raw.githubusercontent.com/vilaca/awesome-k8s-tools/main/data/repos
| cut -d '/' -f4-5 \
| while read repo; do echo "$(curl -s "https://api.github.com/repos/$repo" --header "Authorization: Bearer $PAT" \
| jq .stargazers_count) $repo"; done \
> $(date +"%d-%m-%Y")
> data/$(date +"%d-%m-%Y")

2 changes: 1 addition & 1 deletion scripts/score.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

rm score-output
echo "Scoring $1 <- $2"

declare -A stars

Expand Down
5 changes: 5 additions & 0 deletions scripts/utils/sevenDaysAgo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
current_date=$(date +%s)
seven_days=$((7 * 24 * 60 * 60))
seven_days_ago=$((current_date - seven_days))
seven_days_ago_date=$(date -d "@$seven_days_ago" +%d-%m-%Y)
echo $seven_days_ago_date
1 change: 1 addition & 0 deletions scripts/utils/today.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo $(date +"%d-%m-%Y")

0 comments on commit 94da679

Please sign in to comment.