name: Autoupdate project structure on: workflow_dispatch: schedule: - cron: "0 0 * * *" # at the end of every day jobs: auto-update-project: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v6 with: python-version: "3.14" - name: Install dependencies run: python -m pip install cruft poetry jello tabulate - name: Update project structure run: | cruft update -y - name: Check if there are changes id: changes run: echo "::set-output name=changed::$(git status --porcelain | wc -l)" - name: apply additional changes and fixes if: steps.changes.outputs.changed > 0 run: | poetry lock --no-update # add new dependencies poetry install poetry run pre-commit run -a || true # we have to fix other issues manually - name: Get template versions id: get_versions if: steps.changes.outputs.changed > 0 shell: bash run: | CURRENT_VERSION=$(git show HEAD:.cruft.json | jello -r "_['commit'][:8]") NEXT_VERSION=$(jello -r "_['commit'][:8]" < .cruft.json) echo ::set-output name="current_version::$CURRENT_VERSION" echo ::set-output name="next_version::$NEXT_VERSION" - name: Get changelog id: get_changelog if: steps.changes.outputs.changed > 0 shell: bash run: | TEMPLATE=$(jello -r "_['template']" < .cruft.json) git clone "$TEMPLATE" /tmp/template cd /tmp/template body=$( (echo "Date;Change;Hash"; git log --pretty=format:"%as;%s;%h" ${{ steps.get_versions.outputs.current_version }}..${{ steps.get_versions.outputs.next_version }}) | tabulate --header --format github -s ';' -) body=$(cat < 0 && env.GITHUB_TOKEN != 0 }} uses: peter-evans/create-pull-request@v7 with: token: ${{ env.GITHUB_TOKEN }} commit-message: >- chore: update project structure to ${{ steps.get_versions.outputs.next_version }} title: "[Actions] Auto-Update cookiecutter template" body: ${{ steps.get_changelog.outputs.changelog }} branch: chore/auto-update-project-from-template delete-branch: true