Skip to content

Commit 96e2b99

Browse files
committed
add workflow to update main
1 parent 02124d2 commit 96e2b99

4 files changed

Lines changed: 109 additions & 5 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build and Deploy Template
2+
3+
on:
4+
push:
5+
branches:
6+
- template
7+
8+
jobs:
9+
test-and-deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
steps:
16+
- name: Checkout template branch
17+
uses: actions/checkout@v4
18+
with:
19+
ref: template
20+
fetch-depth: 0
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
24+
25+
- name: Run template tests
26+
run: make test
27+
28+
- name: Configure Git
29+
run: |
30+
git config user.name "github-actions[bot]"
31+
git config user.email "github-actions[bot]@users.noreply.github.com"
32+
33+
- name: Build template output
34+
run: make build
35+
36+
- name: Run pre-commit on build output
37+
working-directory: build_output
38+
run: |
39+
uvx prek install
40+
uvx prek run --all-files
41+
42+
- name: Get template commit SHA
43+
id: template_sha
44+
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
45+
46+
- name: Prepare workspace for PR
47+
run: |
48+
# Remove all files except .git directory and build_output
49+
find . -mindepth 1 -maxdepth 1 ! -name '.git' ! -name 'build_output' -exec rm -rf {} +
50+
# Move build output contents to root
51+
mv build_output/* build_output/.* . 2>/dev/null || true
52+
# Remove the now-empty build_output directory
53+
rmdir build_output 2>/dev/null || true
54+
55+
- name: Create Pull Request
56+
uses: peter-evans/create-pull-request@v7
57+
with:
58+
token: ${{ secrets.GITHUB_TOKEN }}
59+
commit-message: "Build from template@${{ steps.template_sha.outputs.sha }}"
60+
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
61+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
62+
branch: template-build
63+
delete-branch: true
64+
base: main
65+
title: "Build from template@${{ steps.template_sha.outputs.sha }}"
66+
body: |
67+
## 🤖 Automated Template Build
68+
69+
This PR contains the rendered template from the latest changes on the `template` branch.
70+
71+
**Source commit:** `${{ steps.template_sha.outputs.sha }}`
72+
**Build timestamp:** ${{ github.event.head_commit.timestamp }}
73+
74+
### ✅ Validation
75+
- Template tests passed
76+
- Pre-commit hooks validated
77+
78+
---
79+
Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
80+
labels: |
81+
automated
82+
template-build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copier template testing outputs
22
temp_out/
33
test_output/
4+
build_output/
45

56
# Python cache from test runs
67
__pycache__/

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SHELL := /bin/bash
2-
.PHONY: test
2+
.PHONY: test build clean
33

44
test:
55
@set -euo pipefail; \
@@ -9,9 +9,21 @@ test:
99
cd "$$tmpdir"; \
1010
echo "🌀 Initializing git repo..."; \
1111
git add -A >/dev/null; \
12-
uvx pre-commit install >/dev/null; \
12+
uvx prek install >/dev/null; \
1313
echo "🚀 Running pre-commit hooks..."; \
14-
uvx pre-commit run --all-files; \
14+
uvx prek run --all-files; \
1515
cd - >/dev/null; \
1616
rm -rf "$$tmpdir"; \
1717
echo "✅ All checks passed and temp folder cleaned up."
18+
19+
build:
20+
@echo "🔧 Generating template into: build_output/"
21+
@rm -rf build_output
22+
@uvx copier copy . build_output --defaults --force --trust --data skip_git_init=true
23+
@echo "✅ Template generated successfully!"
24+
@echo "📁 Check the output in: build_output/"
25+
26+
clean:
27+
@echo "🧹 Cleaning build output..."
28+
@rm -rf build_output
29+
@echo "✅ Cleaned!"

copier.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ use_github_actions:
6161
help: Include GitHub Actions CI configuration?
6262
default: yes
6363

64+
skip_git_init:
65+
type: bool
66+
when: false # Hidden parameter for testing
67+
default: no
68+
6469
_tasks:
65-
- "git init"
66-
- "uvx prek install"
70+
- command: "git init"
71+
description: "🌀 Initializing git repository"
72+
when: "{{ not skip_git_init }}"
73+
- command: "uvx prek install"
74+
description: "🔧 Installing pre-commit hooks"
75+
when: "{{ not skip_git_init }}"

0 commit comments

Comments
 (0)