Skip to content

Commit

Permalink
Initial cruft update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
CyclingNinja committed Nov 23, 2023
1 parent 4c7b435 commit d837295
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"template": "https://github.com/CyclingNinja/packaging-guide",
"commit": "8fbd8e7825ca747dece08c592965570403e25fec",
"checkout": null,
"context": {
"cookiecutter": {
"package_name": "test_sub_package",
"module_name": "sub_package",
"short_description": "a package",
"author_name": "sam bennett",
"author_email": "[email protected]",
"license": "BSD 3-Clause",
"project_url": "a_project.com",
"minimum_python_version": "3.8",
"use_compiled_extensions": "n",
"include_example_code": "y",
"_sphinx_theme": "alabaster",
"_parent_project": "",
"_install_requires": "",
"_copy_without_render": [
"docs/_templates",
"docs/_static"
],
"_template": "https://github.com/CyclingNinja/packaging-guide"
}
},
"directory": null
}
77 changes: 77 additions & 0 deletions .github/workflows/sub_package_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Update SunPy Sub Packages
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: "SunPy package template update"
title: New Updates to SunPy 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 SunPy template updates

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'
# this needs to be sunpy details I think?
run: |
git config --global user.email ""
git config --global user.name "SunPy Org"
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 SunPy Package Template

0 comments on commit d837295

Please sign in to comment.