From 4b37cecde47ae43e1deb8a9688fe088426e7397c Mon Sep 17 00:00:00 2001 From: shupershuff <63577525+shupershuff@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:24:24 +1200 Subject: [PATCH] Create GetDownloadCount --- .github/workflows/GetDownloadCount | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/GetDownloadCount diff --git a/.github/workflows/GetDownloadCount b/.github/workflows/GetDownloadCount new file mode 100644 index 0000000..366c3ba --- /dev/null +++ b/.github/workflows/GetDownloadCount @@ -0,0 +1,42 @@ +name: Update Download Count + +on: + schedule: + #- cron: '0 0 * * *' # Runs daily at midnight + - cron: '0 * * * *' # Runs every hour + workflow_dispatch: + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Fetch Release Data + id: fetch_release + run: | + release_data=$(curl -s https://api.github.com/repos/shupershuff/diablo2rloader/releases/latest) + echo "::set-output name=release_data::${release_data}" + + - name: Calculate Download Count + id: calculate_downloads + run: | + download_count=$(echo "${{ steps.fetch_release.outputs.release_data }}" | jq '[.assets[].download_count] | add') + echo "::set-output name=download_count::${download_count}" + + - name: Update JSON File + run: | + echo '{ + "schemaVersion": 1, + "label": "downloads", + "message": "'${{ steps.calculate_downloads.outputs.download_count }}'", + "color": "blue" + }' > download-count.json + + git config --global user.name 'github-actions' + git config --global user.email 'github-actions@github.com' + git add download-count.json + git commit -m 'Update download count' + git push