Pipfile.locks Renewal Action #7
This file contains hidden or 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
| --- | |
| # This GitHub action is meant to update the pipfile.locks | |
| name: Pipfile.locks Renewal Action | |
| on: # yamllint disable-line rule:truthy | |
| # Triggers the workflow every Wednesday at 1am UTC | |
| schedule: | |
| - cron: "0 1 * * 3" | |
| workflow_dispatch: # for manual trigger workflow from GH Web UI | |
| inputs: | |
| branch: | |
| description: 'Specify branch' | |
| required: false | |
| default: 'main' | |
| python_version: | |
| description: 'Select a Python version to update Pipfile.lock' | |
| required: false | |
| default: '["3.11", "3.12"]' | |
| type: choice | |
| options: | |
| - '["3.11", "3.12"]' | |
| - '["3.12"]' | |
| - '["3.11"]' | |
| - '["3.9"]' | |
| - '["3.8"]' | |
| lockfiles_upgrade: | |
| description: 'Force full relock and upgrades for pylock.toml (manual runs)' | |
| required: false | |
| default: 'false' | |
| type: choice | |
| options: | |
| - 'true' | |
| - 'false' | |
| update_optional_dirs: | |
| description: 'Include optional directories in update' | |
| required: false | |
| default: 'false' | |
| type: choice | |
| options: | |
| - 'true' | |
| - 'false' | |
| jobs: | |
| refresh-pipfile-locks: | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: refresh-pipfile-locks-${{ matrix.python-version }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: >- | |
| ${{ fromJSON( github.event.inputs.python_version || '["3.11", "3.12"]' ) }} | |
| permissions: | |
| contents: write | |
| env: | |
| BRANCH: ${{ github.event.inputs.branch || 'main' }} | |
| INCLUDE_OPT_DIRS: ${{ github.event.inputs.update_optional_dirs || 'false' }} | |
| # Force full relock on scheduled runs. For manual runs, use the input toggle. | |
| FORCE_LOCKFILES_UPGRADE: ${{ github.event_name == 'schedule' && '1' || (github.event.inputs.lockfiles_upgrade == 'true' && '1' || '0') }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ env.BRANCH }} | |
| token: ${{ secrets.GH_ACCESS_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "GitHub Actions" | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install pipenv | |
| run: pip install "pipenv==2025.0.4" | |
| - name: Install uv | |
| run: pip install "uv==0.8.12" | |
| - name: Run make refresh-pipfilelock-files | |
| run: | | |
| make refresh-pipfilelock-files PYTHON_VERSION=${{ matrix.python-version }} INCLUDE_OPT_DIRS=${{ env.INCLUDE_OPT_DIRS }} | |
| env: | |
| FORCE_LOCKFILES_UPGRADE: ${{ env.FORCE_LOCKFILES_UPGRADE }} | |
| - name: Commit changes (if any) | |
| run: | | |
| git add . | |
| git diff --cached --quiet && echo "No changes to commit." || git commit -m "Update Pipfile.lock for Python ${{ matrix.python-version }}" | |
| - name: Pull and push changes | |
| run: | | |
| git pull --rebase origin ${{ env.BRANCH }} | |
| git push origin ${{ env.BRANCH }} |