CD - Check dependencies #164
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
| name: CD - Check dependencies | |
| on: | |
| schedule: | |
| # At 7:30 every Monday (5:30 UTC) | |
| - cron: "30 5 * * 1" | |
| workflow_dispatch: | |
| jobs: | |
| # Do not use SINTEF/ci-cd as it cannot run for a pyproject.toml file in a sub-folder. | |
| update-dependencies: | |
| name: Update dependencies | |
| if: github.repository_owner == 'EMMC-ASBL' | |
| runs-on: ubuntu-latest | |
| env: | |
| GIT_USER_NAME: "TEAM 4.0[bot]" | |
| GIT_USER_EMAIL: "Team4.0@SINTEF.no" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: master | |
| fetch-depth: 0 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Set up git user info | |
| run: | | |
| git config --global user.name "${{ env.GIT_USER_NAME }}" | |
| git config --global user.email "${{ env.GIT_USER_EMAIL }}" | |
| - name: Install necessary dependencies | |
| run: | | |
| python -m pip install -U pip | |
| pip install -U setuptools wheel | |
| pip install -r requirements.txt | |
| - name: Update pyproject.toml dependencies | |
| id: update_pyproject | |
| run: | | |
| pre-commit run --all-files --hook-stage=manual update-pyproject || CHECK_FAILED=true | |
| if [ -n "$(git status --porcelain {{\ cookiecutter.project_slug\ }}/pyproject.toml)" ]; then | |
| echo "update_deps=true" >> $GITHUB_OUTPUT | |
| git add {{\ cookiecutter.project_slug\ }}/pyproject.toml | |
| git commit -m "Update dependencies" | |
| else | |
| if [ -n "${CHECK_FAILED}" ]; then | |
| echo "The pre-commit hook failed (no changes to pyproject.toml)." | |
| exit 1 | |
| fi | |
| echo "update_deps=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Fetch PR body | |
| if: steps.update_pyproject.outputs.update_deps == 'true' | |
| id: pr_body | |
| uses: chuhlomin/render-template@v1.10 | |
| with: | |
| template: .github/utils/pyproject_toml_update_pr_body.txt | |
| - name: Create PR | |
| if: steps.update_pyproject.outputs.update_deps == 'true' | |
| id: cpr | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.RELEASE_PAT }} | |
| committer: "${{ env.GIT_USER_NAME }} <${{ env.GIT_USER_EMAIL }}>" | |
| author: "${{ env.GIT_USER_NAME }} <${{ env.GIT_USER_EMAIL }}>" | |
| branch: ci/update-pyproject | |
| delete-branch: true | |
| title: "[Auto-generated] Update dependencies (`pyproject.toml`)" | |
| body: ${{ steps.pr_body.outputs.result }} | |
| labels: CI/CD,skip-changelog | |
| - name: Information | |
| run: 'echo "${{ steps.cpr.outputs.pull-request-operation }} PR #${{ steps.cpr.outputs.pull-request-number }}: ${{ steps.cpr.outputs.pull-request-url }}"' |