Skip to content

Commit e6bbf88

Browse files
committed
feat: ✨ add test and update-from-template workflows
1 parent 265bcaa commit e6bbf88

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

.github/workflows/test.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test template creation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
# Least privilege permissions
10+
permissions: read-all
11+
12+
jobs:
13+
test-copier:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
18+
19+
- name: Set up uv
20+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba
21+
with:
22+
enable-cache: true
23+
24+
- name: Set up Quarto
25+
uses: quarto-dev/quarto-actions/setup@9e48da27e184aa238fcb49f5db75469626d43adb # v2.1.9
26+
27+
- name: Install justfile
28+
run: sudo apt install -y just
29+
30+
- name: Set Git user
31+
run: |
32+
git config --global user.name "GitHub Actions"
33+
git config --global user.email "[email protected]"
34+
35+
- name: Test and check template creation
36+
run: just _tests
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)