|
| 1 | +name: Sync Configurable Files from Parent Repository |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Schedule will be dynamically loaded from sync-config.yml if available |
| 6 | + - cron: '0 9 * * 1' # Default value, overridden by config if present |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + parent_repo: |
| 10 | + description: 'Parent repository (owner/repo)' |
| 11 | + required: false |
| 12 | + default: '' |
| 13 | + parent_branch: |
| 14 | + description: 'Parent repository branch' |
| 15 | + required: false |
| 16 | + default: '' |
| 17 | + files_to_sync: |
| 18 | + description: 'Comma-separated list of files to sync (leave empty for config file)' |
| 19 | + required: false |
| 20 | + default: '' |
| 21 | + use_config_file: |
| 22 | + description: 'Use .github/sync-config.yml for configuration' |
| 23 | + required: false |
| 24 | + default: true |
| 25 | + type: boolean |
| 26 | + |
| 27 | +env: |
| 28 | + CONFIG_FILE: '.github/sync-config.yml' |
| 29 | + |
| 30 | +jobs: |
| 31 | + sync-files: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + permissions: |
| 34 | + contents: write |
| 35 | + pull-requests: write |
| 36 | + actions: write |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout current repository |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + token: ${{ secrets.SYNC_PAT || secrets.GITHUB_TOKEN }} |
| 43 | + fetch-depth: 0 |
| 44 | + |
| 45 | + - name: Setup Git and Sync Files with PowerShell |
| 46 | + id: sync |
| 47 | + shell: pwsh |
| 48 | + env: |
| 49 | + GITHUB_TOKEN: ${{ secrets.SYNC_PAT || secrets.GITHUB_TOKEN }} |
| 50 | + HAS_SYNC_PAT: ${{ secrets.SYNC_PAT != '' }} |
| 51 | + run: | |
| 52 | + git config --global user.name "github-actions[bot]" |
| 53 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 54 | + ./.github/scripts/sync-configurable-files.ps1 |
| 55 | +
|
| 56 | + - name: Create Pull Request |
| 57 | + if: steps.sync.outputs.changes_made == 'true' |
| 58 | + uses: peter-evans/create-pull-request@v6 |
| 59 | + with: |
| 60 | + token: ${{ secrets.SYNC_PAT || secrets.GITHUB_TOKEN }} |
| 61 | + commit-message: | |
| 62 | + Sync configurable files from parent repository |
| 63 | +
|
| 64 | + Updated files: ${{ env.CHANGED_FILES }} |
| 65 | + Source: ${{ steps.sync.outputs.parent_repo }}@${{ steps.sync.outputs.parent_branch }} |
| 66 | +
|
| 67 | + 🤖 Generated with GitHub Actions |
| 68 | + title: 'Sync configurable files from parent repository' |
| 69 | + body: | |
| 70 | + ## Sync Configurable Files |
| 71 | +
|
| 72 | + This PR updates configurable files from the parent repository to maintain consistency. |
| 73 | +
|
| 74 | + **Source Repository:** `${{ steps.sync.outputs.parent_repo }}` |
| 75 | + **Source Branch:** `${{ steps.sync.outputs.parent_branch }}` |
| 76 | +
|
| 77 | + ### Files Updated |
| 78 | + ${{ env.CHANGED_FILES }} |
| 79 | +
|
| 80 | + ### Files That Failed to Download |
| 81 | + ${{ env.FAILED_FILES }} |
| 82 | +
|
| 83 | + ### Configuration |
| 84 | + This workflow can be customized by: |
| 85 | + - Modifying the `DEFAULT_FILES` environment variable in the workflow |
| 86 | + - Using the manual trigger with custom file lists |
| 87 | + - Adjusting the cron schedule for different sync frequencies |
| 88 | +
|
| 89 | + --- |
| 90 | +
|
| 91 | + 🤖 This PR was created automatically by the sync-configurable-files workflow. |
| 92 | + branch: sync-configurable-files |
| 93 | + branch-suffix: timestamp |
| 94 | + delete-branch: true |
| 95 | + |
| 96 | + - name: Output summary (already handled in PowerShell script) |
| 97 | + shell: pwsh |
| 98 | + run: | |
| 99 | + Write-Host "Summary has been written by the PowerShell script." |
0 commit comments