|
| 1 | +# SPDX-FileCopyrightText: 2019 Michael Schroeder |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +name: Run Daily Reports |
| 6 | + |
| 7 | +on: |
| 8 | + schedule: |
| 9 | + # The actor (github.actor) that runs the cron job may be the user who created the cron job |
| 10 | + # initially. It does not appear to be settable via a secret or environment variable. |
| 11 | + - cron: 15 5 * * * |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | + |
| 15 | +jobs: |
| 16 | + check-repo-owner: |
| 17 | + # This job is so the entire workflow will end successfully and give some |
| 18 | + # output to explain why it hasn't run on a non-Adafruit fork. |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: repository |
| 22 | + env: |
| 23 | + OWNER_IS_ADAFRUIT: ${{ startswith(github.repository, 'adafruit/') }} |
| 24 | + run: | |
| 25 | + echo "This workflow will only run if Adafruit is the repository owner." |
| 26 | + echo "Repository owner is Adafruit: $OWNER_IS_ADAFRUIT" |
| 27 | + run-reports: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + # Only run the build on Adafruit's repository. Forks won't have the secrets. |
| 30 | + # It's necessary to do this here, since 'schedule' events cannot (currently) |
| 31 | + # be limited (they run on all forks' default branches). |
| 32 | + if: startswith(github.repository, 'adafruit/') |
| 33 | + env: |
| 34 | + ADABOT_GITHUB_USER: ${{ secrets.ADABOT_GITHUB_USER }} |
| 35 | + ADABOT_GITHUB_ACCESS_TOKEN: ${{ secrets.ADABOT_GITHUB_ACCESS_TOKEN }} |
| 36 | + RTD_TOKEN: ${{ secrets.RTD_TOKEN }} |
| 37 | + BIGQUERY_PRIVATE_KEY: ${{ secrets.BIGQUERY_PRIVATE_KEY }} |
| 38 | + BIGQUERY_CLIENT_EMAIL: ${{ secrets.BIGQUERY_CLIENT_EMAIL }} |
| 39 | + steps: |
| 40 | + - name: Set up Python 3.11 |
| 41 | + uses: actions/setup-python@v5 |
| 42 | + with: |
| 43 | + python-version: 3.11 |
| 44 | + - name: Versions |
| 45 | + run: | |
| 46 | + python3 --version |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + repository: 'adafruit/adabot' |
| 50 | + submodules: true |
| 51 | + - name: Install deps |
| 52 | + run: | |
| 53 | + pip install -r requirements.txt |
| 54 | + - name: Make Directory For Report Files |
| 55 | + run: mkdir -p bin/adabot |
| 56 | + - name: Set Date Variable |
| 57 | + id: today |
| 58 | + run: | |
| 59 | + echo date=$( |
| 60 | + date +%Y%m%d |
| 61 | + ) >> $GITHUB_OUTPUT |
| 62 | + - name: Run adabot.circuitpython_libraries |
| 63 | + env: |
| 64 | + # LIB_CHECK_CP_FILE is for circuitpython_libraries.py output |
| 65 | + LIB_CHECK_CP_FILE: bin/adabot/circuitpython_library_report_${{ steps.today.outputs.date }}.txt |
| 66 | + run: | |
| 67 | + python3 -u -m adabot.circuitpython_libraries -o $LIB_CHECK_CP_FILE |
| 68 | + continue-on-error: true |
| 69 | + - name: Run adabot.circuitpython_library_download_stats |
| 70 | + env: |
| 71 | + # LIB_DL_STATS_FILE is for future Bundle and PyPi download stats script |
| 72 | + LIB_DL_STATS_FILE: bin/adabot/library_download_stats_${{ steps.today.outputs.date }}.txt |
| 73 | + run: | |
| 74 | + python3 -u -m adabot.circuitpython_library_download_stats -o $LIB_DL_STATS_FILE |
| 75 | + continue-on-error: true |
| 76 | + - name: Run adabot.arduino_libraries |
| 77 | + env: |
| 78 | + # LIB_CHECK_ARD_FILE is for arduino_libraries.py output |
| 79 | + LIB_CHECK_ARD_FILE: bin/adabot/arduino_library_report_${{ steps.today.outputs.date }}.txt |
| 80 | + run: | |
| 81 | + python3 -u -m adabot.arduino_libraries -o $LIB_CHECK_ARD_FILE |
| 82 | + continue-on-error: true |
| 83 | + - name: Check For Files |
| 84 | + run: | |
| 85 | + ls bin/adabot |
| 86 | + - name: Upload Reports To AWS S3 |
| 87 | + if: ${{ github.event_name != 'workflow_dispatch' }} |
| 88 | + env: |
| 89 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 90 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 91 | + run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/adabot/ s3://adafruit-circuit-python/adabot/bin/reports/ --recursive --no-progress --region us-east-1" |
0 commit comments