Skip to content

Commit b796afb

Browse files
authored
feat: ✨ workflow to check for updates and make a PR with them (#135)
# Description This adds a workflow to the created template that will run every day to check for updates from the template. If there is an update, it will make a pull request of those changes. I don't know if it will work though, so we'll have to see how it works in the data packages that use this template. Closes #38 This PR needs an in-depth review. ## Checklist - [x] Ran `just run-all`
1 parent a0ddc29 commit b796afb

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Update from template
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Every day at 3:30 at night.
7+
- cron: '30 3 * * *'
8+
9+
# Limit token permissions for security
10+
permissions: read-all
11+
12+
jobs:
13+
update-from-template:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
pull-requests: write
17+
steps:
18+
- name: Harden the runner (Audit all outbound calls)
19+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
20+
with:
21+
egress-policy: audit
22+
23+
- name: Check out repository
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
26+
- name: Install Python
27+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
28+
with:
29+
python-version: "3.13"
30+
31+
- name: Install dependencies
32+
run: |
33+
sudo apt install pipx
34+
pipx ensurepath
35+
pipx install uv rust-just copier
36+
37+
- name: Set User
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
41+
42+
- name: Pull request with updates from template
43+
run: |
44+
copier update --trust --defaults --overwrite
45+
any_changes=$(git status --porcelain=v1 2>/dev/null | wc -l)
46+
if [ "$any_changes" -eq 0 ]; then
47+
echo "No updates from the template detected, and no changes found. Stopping and exiting."
48+
exit 0
49+
fi
50+
git checkout -b chore/update-from-template
51+
git add .
52+
git commit -m "chore(sync): :hammer: update changes from template"
53+
gh pr create \
54+
--title "chore(sync): :hammer: update changes from template" \
55+
--body "This PR is automatically generated by the 'update-from-template' workflow. It syncs the latest changes from the template repository with this repository."

0 commit comments

Comments
 (0)