Fetch anaconda.org stats #2789
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Fetch anaconda.org stats | |
on: | |
schedule: | |
- cron: '0 3,9,15,21 * * *' | |
workflow_dispatch: | |
pull_request: | |
jobs: | |
fetch-anaconda-org-stats: | |
name: Fetch anaconda.org stats | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check | |
id: check | |
run: | | |
pip install \ | |
ntplib | |
time="$( | |
export PYTHONPATH="$( pwd )/src" | |
python -m package_downloads.ntp_time | |
)" | |
if git ls-remote --exit-code --quiet --tags -- origin "${time}" ; then | |
echo "skip=1" >> "${GITHUB_OUTPUT}" | |
else | |
echo "skip=0" >> "${GITHUB_OUTPUT}" | |
fi | |
- if: ${{ github.ref != 'refs/heads/main' || steps.check.outputs.skip == '0' }} | |
name: Fetch | |
id: fetch | |
run: | | |
set -x | |
ref="$( git show-ref --head --hash HEAD )" | |
pip install \ | |
ntplib \ | |
aiohttp requests urllib3 \ | |
pandas | |
git fetch --depth=1 origin data:data | |
git checkout --quiet data | |
git checkout --quiet "${ref}" -- ./src | |
time="$( | |
export PYTHONPATH="$( pwd )/src" | |
python -m package_downloads.stats_from_anaconda_org | |
)" | |
echo "time=${time}" >> "${GITHUB_OUTPUT}" | |
- if: ${{ github.ref != 'refs/heads/main' || steps.check.outputs.skip == '0' }} | |
name: Add changes, commit | |
run: | | |
set -x | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add -A ./package-downloads | |
git rm -rf ./src | |
git status --short | grep -o ^. | sort | uniq -c | |
git commit -qm 'Update package download stats, ${{ steps.fetch.outputs.time }}' | |
git tag '${{ steps.fetch.outputs.time }}' | |
- if: ${{ github.ref == 'refs/heads/main' && steps.check.outputs.skip == '0' }} | |
name: Push changes | |
run: | | |
git push --tags origin data:data |