|
18 | 18 | - '.github/workflows/monorepo-split-plan.yml' |
19 | 19 | - 'src/SonsOfPHP/**/composer.json' |
20 | 20 | - 'src/**' |
| 21 | + workflow_dispatch: |
| 22 | + inputs: |
| 23 | + base: |
| 24 | + description: 'Base git ref for changed-package replay' |
| 25 | + required: false |
| 26 | + head: |
| 27 | + description: 'Head git ref to check out and publish' |
| 28 | + required: true |
| 29 | + default: 'main' |
| 30 | + tag: |
| 31 | + description: 'Optional release tag to publish instead of a branch range' |
| 32 | + required: false |
| 33 | + publish: |
| 34 | + description: 'Actually push split refs instead of calculating only' |
| 35 | + required: true |
| 36 | + type: boolean |
| 37 | + default: false |
21 | 38 |
|
22 | 39 | permissions: |
23 | 40 | contents: read |
|
35 | 52 | with: |
36 | 53 | fetch-depth: 0 |
37 | 54 | persist-credentials: false |
| 55 | + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.head || github.ref }} |
38 | 56 | - uses: shivammathur/setup-php@v2 |
39 | 57 | with: |
40 | 58 | php-version: '8.3' |
@@ -63,14 +81,14 @@ jobs: |
63 | 81 | splitsh-lite --help |
64 | 82 | - uses: actions/create-github-app-token@v3 |
65 | 83 | id: app-token |
66 | | - if: github.event_name == 'push' |
| 84 | + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish) |
67 | 85 | with: |
68 | 86 | client-id: ${{ secrets.MONOREPO_SPLIT_APP_CLIENT_ID }} |
69 | 87 | private-key: ${{ secrets.MONOREPO_SPLIT_APP_PRIVATE_KEY }} |
70 | 88 | owner: ${{ github.repository_owner }} |
71 | 89 | permission-contents: write |
72 | 90 | - name: Configure read-only repo token auth |
73 | | - if: github.event_name == 'push' |
| 91 | + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish) |
74 | 92 | env: |
75 | 93 | MONOREPO_SPLIT_TOKEN: ${{ steps.app-token.outputs.token }} |
76 | 94 | run: | |
@@ -101,3 +119,29 @@ jobs: |
101 | 119 | --tag='${{ github.ref_name }}' \ |
102 | 120 | --origin='${{ github.ref }}' \ |
103 | 121 | --publish |
| 122 | + - name: Run manual split replay |
| 123 | + if: github.event_name == 'workflow_dispatch' |
| 124 | + env: |
| 125 | + BASE_REF: ${{ inputs.base }} |
| 126 | + HEAD_REF: ${{ inputs.head }} |
| 127 | + TAG_NAME: ${{ inputs.tag }} |
| 128 | + PUBLISH_SPLITS: ${{ inputs.publish }} |
| 129 | + run: | |
| 130 | + if [ -n "$TAG_NAME" ]; then |
| 131 | + command=(php .github/scripts/monorepo-split-plan.php --tag="$TAG_NAME" --origin="refs/tags/$TAG_NAME") |
| 132 | + else |
| 133 | + if [ -z "$BASE_REF" ]; then |
| 134 | + echo "::error::Manual branch replay requires the base input." |
| 135 | + exit 1 |
| 136 | + fi |
| 137 | +
|
| 138 | + command=(php .github/scripts/monorepo-split-plan.php --base="$BASE_REF" --head="$HEAD_REF" --origin=HEAD) |
| 139 | + fi |
| 140 | +
|
| 141 | + if [ "$PUBLISH_SPLITS" = "true" ]; then |
| 142 | + command+=(--publish) |
| 143 | + else |
| 144 | + command+=(--calculate-splits) |
| 145 | + fi |
| 146 | +
|
| 147 | + "${command[@]}" |
0 commit comments