|
| 1 | +# /.github/workflows/cruft-update.yml |
| 2 | +name: Update repository with Cruft |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + pull-requests: write |
| 6 | + actions: write |
| 7 | +on: |
| 8 | + schedule: |
| 9 | + - cron: "0 * * * *" # Once per hour |
| 10 | + workflow_dispatch: {} |
| 11 | + |
| 12 | +jobs: |
| 13 | + update: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + fail-fast: true |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - add-paths: . |
| 20 | + body: Use this to merge the changes to this repository. |
| 21 | + branch: cruft/update |
| 22 | + commit-message: "chore: accept new Cruft update" |
| 23 | + title: New updates detected with Cruft |
| 24 | + - add-paths: .cruft.json |
| 25 | + body: Use this to reject the changes in this repository. |
| 26 | + branch: cruft/reject |
| 27 | + commit-message: "chore: reject new Cruft update" |
| 28 | + title: Reject new updates detected with Cruft |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + token: ${{ secrets.COMPONENT_ACCESS_TOKEN }} |
| 33 | + |
| 34 | + - uses: actions/setup-python@v5 |
| 35 | + with: |
| 36 | + python-version: "3.10" |
| 37 | + |
| 38 | + - name: Install Cruft |
| 39 | + run: pip3 install cruft |
| 40 | + |
| 41 | + - name: Check if update is available |
| 42 | + continue-on-error: false |
| 43 | + id: check |
| 44 | + run: | |
| 45 | + CHANGES=0 |
| 46 | + if [ -f .cruft.json ]; then |
| 47 | + if ! cruft check; then |
| 48 | + CHANGES=1 |
| 49 | + fi |
| 50 | + else |
| 51 | + echo "No .cruft.json file" |
| 52 | + fi |
| 53 | +
|
| 54 | + echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT" |
| 55 | +
|
| 56 | + - name: Run update if available |
| 57 | + if: steps.check.outputs.has_changes == '1' |
| 58 | + run: | |
| 59 | + git config --global user.email "githubbot@vshn.ch" |
| 60 | + git config --global user.name "GitHubBot" |
| 61 | +
|
| 62 | + cruft update --skip-apply-ask --refresh-private-variables |
| 63 | + git restore --staged . |
| 64 | +
|
| 65 | + - name: Create pull request |
| 66 | + if: steps.check.outputs.has_changes == '1' |
| 67 | + uses: peter-evans/create-pull-request@v6 |
| 68 | + with: |
| 69 | + token: ${{ secrets.COMPONENT_ACCESS_TOKEN }} |
| 70 | + add-paths: ${{ matrix.add-paths }} |
| 71 | + commit-message: ${{ matrix.commit-message }} |
| 72 | + branch: ${{ matrix.branch }} |
| 73 | + delete-branch: true |
| 74 | + title: ${{ matrix.title }} |
| 75 | + labels: dependency |
| 76 | + body: | |
| 77 | + This is an autogenerated PR. ${{ matrix.body }} |
| 78 | +
|
| 79 | + [Cruft](https://cruft.github.io/cruft/) has detected updates from the Cookiecutter repository. |
0 commit comments