Skip to content

Commit ddcbe9e

Browse files
authored
chore: cruft update (#421)
## Summary by Sourcery Allow customizing cruft sub-package updates via workflow inputs and adjust GitHub workflow permissions and credentials for automated update PRs. Enhancements: - Add workflow_dispatch input for passing extra cookiecutter context into cruft update runs. - Configure sub_package_update job environment and deployment settings. - Update cruft update step to accept optional variables-to-update arguments from workflow inputs. - Use a dedicated branch token secret for create-pull-request when opening automated update branches. CI: - Adjust GitHub Actions permissions and environment configuration for the sub_package_update workflow.
2 parents 268e891 + a503771 commit ddcbe9e

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

.cruft.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/sunpy/package-template",
3-
"commit": "a31905a50a3889e42d9ca50065a4a4276ea62511",
3+
"commit": "4ba8b7c6a6bf4f51f7154978ae8d2f3710ef89e5",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -22,6 +22,7 @@
2222
"enable_dynamic_dev_versions": "y",
2323
"include_example_code": "y",
2424
"include_cruft_update_github_workflow": "y",
25+
"use_pat_in_cruft_update_workflow": "y",
2526
"use_extended_ruff_linting": "y",
2627
"matrix_room_id": "",
2728
"extra_ci_jobs": "",
@@ -30,11 +31,10 @@
3031
"_install_requires": "",
3132
"_copy_without_render": [
3233
"docs/_templates",
33-
"docs/_static",
34-
".github/workflows/sub_package_update.yml"
34+
"docs/_static"
3535
],
3636
"_template": "https://github.com/sunpy/package-template",
37-
"_commit": "a31905a50a3889e42d9ca50065a4a4276ea62511"
37+
"_commit": "4ba8b7c6a6bf4f51f7154978ae8d2f3710ef89e5"
3838
}
3939
},
4040
"directory": null

.github/workflows/sub_package_update.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ name: Automatic Update from package template
55
on:
66
# Allow manual runs through the web UI
77
workflow_dispatch:
8+
inputs:
9+
extra_context:
10+
description: 'JSON of cookiecutter variables to update (passed to cruft --variables-to-update), e.g. {"project": "new-name"}'
11+
required: false
12+
default: ''
13+
type: string
814
schedule:
915
# ┌───────── minute (0 - 59)
1016
# │ ┌───────── hour (0 - 23)
@@ -19,8 +25,10 @@ jobs:
1925
update:
2026
runs-on: ubuntu-latest
2127
permissions:
22-
contents: write
2328
pull-requests: write
29+
environment:
30+
name: sub_package_update
31+
deployment: false
2432
steps:
2533
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2634
with:
@@ -51,11 +59,18 @@ jobs:
5159
- name: Run update if available
5260
id: cruft_update
5361
if: steps.check.outputs.has_changes == '1'
62+
env:
63+
EXTRA_CONTEXT: ${{ inputs.extra_context }}
5464
run: |
5565
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
5666
git config --global user.name "${GITHUB_ACTOR}"
5767
58-
cruft_output=$(cruft update --skip-apply-ask --refresh-private-variables)
68+
EXTRA_ARGS=()
69+
if [ -n "$EXTRA_CONTEXT" ]; then
70+
EXTRA_ARGS=(--variables-to-update "$EXTRA_CONTEXT")
71+
fi
72+
73+
cruft_output=$(cruft update --skip-apply-ask --refresh-private-variables "${EXTRA_ARGS[@]}")
5974
echo $cruft_output
6075
git restore --staged .
6176
@@ -82,6 +97,7 @@ jobs:
8297
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
8398
with:
8499
token: ${{ secrets.GITHUB_TOKEN }}
100+
branch-token: ${{ secrets.WORKFLOWS_UPDATE_PAT }}
85101
add-paths: "."
86102
commit-message: "Automatic package template update"
87103
branch: "cruft/update"

0 commit comments

Comments
 (0)