|
| 1 | +name: Update Child Repository Template |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + target_repository: |
| 9 | + description: "Target repository to update (default: mjun0812/python-project-template)" |
| 10 | + required: false |
| 11 | + default: "mjun0812/python-project-template" |
| 12 | + |
| 13 | +jobs: |
| 14 | + update-child-template: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout child repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + repository: ${{ github.event.inputs.target_repository || 'mjun0812/python-project-template' }} |
| 21 | + token: ${{ secrets.CHILD_REPO_TOKEN }} |
| 22 | + path: child-repo |
| 23 | + |
| 24 | + - name: Setup Python |
| 25 | + uses: actions/setup-python@v4 |
| 26 | + with: |
| 27 | + python-version: "3.12" |
| 28 | + |
| 29 | + - name: Install uv |
| 30 | + uses: astral-sh/setup-uv@v3 |
| 31 | + |
| 32 | + - name: Update template in child repository |
| 33 | + working-directory: child-repo |
| 34 | + run: | |
| 35 | + # Update from template |
| 36 | + uvx copier update -A --trust gh:${{ github.repository }} |
| 37 | + env: |
| 38 | + COPIER_CONFLICT_STRATEGY: ours |
| 39 | + |
| 40 | + - name: Check for changes |
| 41 | + id: changes |
| 42 | + working-directory: child-repo |
| 43 | + run: | |
| 44 | + if git diff --quiet; then |
| 45 | + echo "has_changes=false" >> $GITHUB_OUTPUT |
| 46 | + else |
| 47 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Create Pull Request |
| 51 | + if: steps.changes.outputs.has_changes == 'true' |
| 52 | + uses: peter-evans/create-pull-request@v5 |
| 53 | + with: |
| 54 | + token: ${{ secrets.CHILD_REPO_TOKEN }} |
| 55 | + path: child-repo |
| 56 | + commit-message: | |
| 57 | + Update template to version ${{ github.event.release.tag_name || 'latest' }} |
| 58 | + title: "Update template to version ${{ github.event.release.tag_name || 'latest' }}" |
| 59 | + body: | |
| 60 | + ## Template Update |
| 61 | +
|
| 62 | + This PR updates the project template to version `${{ github.event.release.tag_name || 'latest' }}`. |
| 63 | +
|
| 64 | + ### Changes |
| 65 | + - Updated from template: ${{ github.repository }} |
| 66 | + - Template version: ${{ github.event.release.tag_name || 'latest' }} |
| 67 | + ${{ github.event.release.html_url && format('- Release notes: {0}', github.event.release.html_url) || '' }} |
| 68 | +
|
| 69 | + ### Testing |
| 70 | + Please review the changes and test the updated template before merging. |
| 71 | +
|
| 72 | + --- |
| 73 | + *This PR was automatically created by the template update workflow.* |
| 74 | + branch: template-update-${{ github.event.release.tag_name || github.run_number }} |
| 75 | + delete-branch: true |
0 commit comments