diff --git a/.cruft.json b/.cruft.json new file mode 100644 index 0000000..8e5edcf --- /dev/null +++ b/.cruft.json @@ -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": "sam.bennett@aperiosoftware.com", + "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 +} diff --git a/.github/workflows/sub_package_update.yml b/.github/workflows/sub_package_update.yml new file mode 100644 index 0000000..2b09443 --- /dev/null +++ b/.github/workflows/sub_package_update.yml @@ -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 +