|
| 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 |
0 commit comments