diff --git a/.github/workflows/fetch.yaml b/.github/workflows/fetch.yaml index b5df7eb..4de3e7b 100644 --- a/.github/workflows/fetch.yaml +++ b/.github/workflows/fetch.yaml @@ -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/push@v1.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ steps.extract_branch.outputs.branch }} - diff --git a/01-03-2024 b/data/01-03-2024 similarity index 100% rename from 01-03-2024 rename to data/01-03-2024 diff --git a/02-03-2024 b/data/02-03-2024 similarity index 100% rename from 02-03-2024 rename to data/02-03-2024 diff --git a/03-03-2024 b/data/03-03-2024 similarity index 100% rename from 03-03-2024 rename to data/03-03-2024 diff --git a/04-03-2024 b/data/04-03-2024 similarity index 100% rename from 04-03-2024 rename to data/04-03-2024 diff --git a/05-03-2024 b/data/05-03-2024 similarity index 100% rename from 05-03-2024 rename to data/05-03-2024 diff --git a/06-03-2024 b/data/06-03-2024 similarity index 100% rename from 06-03-2024 rename to data/06-03-2024 diff --git a/26-02-2024 b/data/26-02-2024 similarity index 100% rename from 26-02-2024 rename to data/26-02-2024 diff --git a/27-02-2024 b/data/27-02-2024 similarity index 100% rename from 27-02-2024 rename to data/27-02-2024 diff --git a/28-02-2024 b/data/28-02-2024 similarity index 100% rename from 28-02-2024 rename to data/28-02-2024 diff --git a/29-02-2024 b/data/29-02-2024 similarity index 100% rename from 29-02-2024 rename to data/29-02-2024 diff --git a/scripts/fetch.sh b/scripts/fetch.sh index 3b0e2f4..42323b4 100755 --- a/scripts/fetch.sh +++ b/scripts/fetch.sh @@ -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") diff --git a/scripts/score.sh b/scripts/score.sh index dac7a62..fe78b67 100755 --- a/scripts/score.sh +++ b/scripts/score.sh @@ -1,5 +1,5 @@ -rm score-output +echo "Scoring $1 <- $2" declare -A stars diff --git a/scripts/utils/sevenDaysAgo.sh b/scripts/utils/sevenDaysAgo.sh new file mode 100755 index 0000000..45128b0 --- /dev/null +++ b/scripts/utils/sevenDaysAgo.sh @@ -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 \ No newline at end of file diff --git a/scripts/utils/today.sh b/scripts/utils/today.sh new file mode 100755 index 0000000..c01d11d --- /dev/null +++ b/scripts/utils/today.sh @@ -0,0 +1 @@ +echo $(date +"%d-%m-%Y") \ No newline at end of file