|
| 1 | +# This is a GitHub workflow defining a set of jobs with a set of steps. |
| 2 | +# ref: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions |
| 3 | +# |
| 4 | +# - Update `requirements.txt` from `requirements.in` with pip-compile |
| 5 | +# |
| 6 | +# About environment: watch-dependencies |
| 7 | +# |
| 8 | +# To reduce the exposure of the secrets.jupyterhub_bot_pat token that was setup |
| 9 | +# for the environment watch-dependencies, we have setup a dedicated environment |
| 10 | +# according to steps in |
| 11 | +# https://github.com/jupyterhub/team-compass/issues/516#issuecomment-1129961954. |
| 12 | + |
| 13 | +name: Watch dependencies |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + paths: |
| 18 | + - "**/requirements.txt" |
| 19 | + - ".github/workflows/watch-dependencies.yaml" |
| 20 | + branches: |
| 21 | + - main |
| 22 | + schedule: |
| 23 | + # Run at 05:00 every day, ref: https://crontab.guru/#0_5_*_*_* |
| 24 | + - cron: "0 5 * * *" |
| 25 | + workflow_dispatch: |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + |
| 30 | +jobs: |
| 31 | + update-image-dependencies: |
| 32 | + # Don't run this job on forks |
| 33 | + if: github.repository == 'jupyterhub/jupyterhub-container-images' |
| 34 | + runs-on: ubuntu-24.04 |
| 35 | + environment: watch-dependencies |
| 36 | + |
| 37 | + strategy: |
| 38 | + matrix: |
| 39 | + image: |
| 40 | + # list of image directories with pip-compile inputs |
| 41 | + # (currently only one) |
| 42 | + - base |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + persist-credentials: false |
| 47 | + - uses: actions/setup-python@v5 |
| 48 | + with: |
| 49 | + # this should match the Python version in base/Dockerfile |
| 50 | + python-version: 3.10 |
| 51 | + - name: install pip-tools |
| 52 | + run: | |
| 53 | + pip install --upgrade pip |
| 54 | + pip install pip-tools |
| 55 | + pip list --format=freeze |
| 56 | +
|
| 57 | + - name: update requirements.txt with pip-compile |
| 58 | + run: | |
| 59 | + pip-compile --allow-unsafe --strip-extras --upgrade |
| 60 | +
|
| 61 | + env: |
| 62 | + CUSTOM_COMPILE_COMMAND: > |
| 63 | + Use the "Run workflow" button at https://github.com/jupyterhub/jupyterhub-container-images/actions/workflows/watch-dependencies.yaml |
| 64 | + working-directory: ${{ matrix.image }} |
| 65 | + |
| 66 | + - name: git diff |
| 67 | + run: git --no-pager diff --color=always |
| 68 | + |
| 69 | + # ref: https://github.com/peter-evans/create-pull-request |
| 70 | + - name: Create a PR |
| 71 | + uses: peter-evans/create-pull-request@v7 |
| 72 | + with: |
| 73 | + token: "${{ secrets.jupyterhub_bot_pat }}" |
| 74 | + author: JupyterHub Bot Account <[email protected]> |
| 75 | + committer: JupyterHub Bot Account <[email protected]> |
| 76 | + branch: update-requirements/${{ matrix.image }} |
| 77 | + labels: dependencies |
| 78 | + commit-message: "${{ matrix.image }}: refreeze requirements.txt" |
| 79 | + title: "${{ matrix.image }}: refreeze requirements.txt" |
| 80 | + body: >- |
| 81 | + The ${{ matrix.image }} requirements.txt has been refrozen with pip-compile. |
0 commit comments