|
| 1 | +name: Template Update |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write # needed to push branch / commits |
| 8 | + pull-requests: write # needed to open PRs |
| 9 | + |
| 10 | +jobs: |
| 11 | + template-update: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + # Hack for setup-python cache (same as your existing Copier workflow) |
| 19 | + - name: Hack for setup-python cache |
| 20 | + run: touch requirements.txt |
| 21 | + |
| 22 | + - name: Setup Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + cache: pip |
| 26 | + python-version: "3.11" |
| 27 | + |
| 28 | + - name: Hack for setup-python cache (cleanup) |
| 29 | + run: rm requirements.txt |
| 30 | + |
| 31 | + - name: Install Copier and pre-commit |
| 32 | + run: | |
| 33 | + pip install copier pre-commit |
| 34 | +
|
| 35 | + - name: Check that answers file exists |
| 36 | + run: | |
| 37 | + if [ ! -f ".copier-answers.jso.yml" ]; then |
| 38 | + echo "::error::.copier-answers.jso.yml not found. \ |
| 39 | +This repo must first be generated from JSOTemplate (or have its answers file added) before it can be updated." |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | + |
| 43 | + - name: Run Copier update from JSOTemplate |
| 44 | + run: | |
| 45 | + # You can add --trust if your template needs it: |
| 46 | + # copier -a .copier-answers.jso.yml update --trust |
| 47 | + copier -a .copier-answers.jso.yml update || true |
| 48 | +
|
| 49 | + - name: Run pre-commit (optional but handy) |
| 50 | + run: | |
| 51 | + pre-commit run -a || true |
| 52 | +
|
| 53 | + - name: Create Pull Request |
| 54 | + id: cpr |
| 55 | + uses: peter-evans/create-pull-request@v7 |
| 56 | + with: |
| 57 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + commit-message: "chore: :robot: template update from JSOTemplate" |
| 59 | + title: "[AUTO] Template update from JSOTemplate" |
| 60 | + body: | |
| 61 | + Automated template update from JSOTemplate. |
| 62 | +
|
| 63 | + This PR was generated by the Template Update workflow using: |
| 64 | + - answers file: .copier-answers.jso.yml |
| 65 | + branch: auto-template-update |
| 66 | + delete-branch: true |
| 67 | + labels: chore, automated pr, no changelog |
| 68 | + |
| 69 | + - name: Check outputs |
| 70 | + run: | |
| 71 | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" |
| 72 | + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
0 commit comments