Local merge #8
This file contains 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 template is taken from the cruft example code, for further information please see: | ||
https://cruft.github.io/cruft/#automating-updates-with-github-actions | ||
""" | ||
name: Automatic Update from package template | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
on: | ||
pull_request: | ||
branches: | ||
main | ||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
include: | ||
- add-paths: . | ||
body: Use this to merge the changes to the repo | ||
branch: cruft/update | ||
commit-message: "Automate package template update" | ||
title: Incoming updates from package template | ||
- add-paths: .cruft.json | ||
body: Use this to reject changes in the repo | ||
branch: cruft/reject | ||
commit-message: "Chore: reject this cruft update" | ||
title: Reject new updates from package template | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install Cruft | ||
run: pip3 install cruft | ||
- name: Check if update is available | ||
continue-on-error: false | ||
id: check | ||
run: | | ||
CHANGES=0 | ||
if [ -f .cruft.json ]; then | ||
if ! cruft check; then | ||
CHANGES=1 | ||
fi | ||
else | ||
echo "No .cruft.json file" | ||
fi | ||
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT" | ||
- name: Run update if available | ||
if: steps.check.outputs.has_changes == '1' | ||
run: | | ||
git config --global user.email "gromit@cruft.com" | ||
git config --global user.name "Gromit" | ||
cruft update --skip-apply-ask --refresh-private-variables | ||
git restore --staged | ||
- name: Create pull request | ||
if: steps.check.output.has_changes == '1' | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
add-paths: ${{ matrix.add-paths }} | ||
commit-message: ${{ matrix.commit-message }} | ||
branch: ${{ matrix.branch }} | ||
delete-branch: true | ||
branch-suffix: timestamp | ||
title: ${{ matrix.title }} | ||
body: | | ||
This is an autogenerated PR. ${{ matrix.body }} | ||
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template |