|
31 | 31 | with: |
32 | 32 | fetch-depth: 0 # Fetch all history for all tags |
33 | 33 | token: ${{ secrets.GITHUB_TOKEN }} |
34 | | - persist-credentials: false |
35 | 34 |
|
36 | 35 | - name: Set up PHP |
37 | 36 | uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2 |
@@ -131,23 +130,40 @@ jobs: |
131 | 130 | STEPS_CHECK_ALIAS_OUTPUTS_BRANCH_KEY: ${{ steps.check_alias.outputs.branch_key }} |
132 | 131 | STEPS_CHECK_ALIAS_OUTPUTS_EXPECTED_ALIAS: ${{ steps.check_alias.outputs.expected_alias }} |
133 | 132 |
|
134 | | - - name: Create Pull Request |
| 133 | + - name: Commit and Create Pull Request |
135 | 134 | if: steps.check_alias.outputs.needs_update == 'true' |
136 | | - uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8 |
137 | | - with: |
138 | | - token: ${{ secrets.GITHUB_TOKEN }} |
139 | | - base: ${{ github.event.repository.default_branch }} |
140 | | - commit-message: "Update branch-alias to ${{ steps.check_alias.outputs.expected_alias }}" |
141 | | - title: "Update branch-alias to ${{ steps.check_alias.outputs.expected_alias }}" |
142 | | - body: | |
| 135 | + env: |
| 136 | + GH_TOKEN: ${{ github.token }} |
| 137 | + PR_BODY: | |
143 | 138 | This PR updates the Composer `branch-alias` configuration to reflect the latest release. |
144 | | - |
| 139 | +
|
145 | 140 | - Latest release: ${{ steps.check_alias.outputs.latest_tag }} |
146 | 141 | - Previous branch-alias: `${{ steps.check_alias.outputs.current_alias }}` |
147 | 142 | - Updated branch-alias: `${{ steps.check_alias.outputs.expected_alias }}` |
148 | | - |
| 143 | +
|
149 | 144 | The branch-alias should point to the major development version for the latest major release. |
150 | | - branch: update-branch-alias |
151 | | - delete-branch: true |
152 | | - labels: | |
153 | | - automated-pr |
| 145 | + run: | |
| 146 | + if [ -n "$(git status --porcelain)" ]; then |
| 147 | + git config user.name "github-actions[bot]" |
| 148 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 149 | + git checkout -b update-branch-alias |
| 150 | + git add composer.json |
| 151 | + git commit -m "Update branch-alias to ${{ steps.check_alias.outputs.expected_alias }}" |
| 152 | + git push -f origin update-branch-alias |
| 153 | + |
| 154 | + PR_NUMBER=$(gh pr list --head update-branch-alias --json number --jq '.[0].number // empty') |
| 155 | + if [ -z "$PR_NUMBER" ]; then |
| 156 | + gh pr create \ |
| 157 | + --title "Update branch-alias to ${{ steps.check_alias.outputs.expected_alias }}" \ |
| 158 | + --body "$PR_BODY" \ |
| 159 | + --label "automated-pr" \ |
| 160 | + --base "${{ github.event.repository.default_branch }}" \ |
| 161 | + --head "update-branch-alias" |
| 162 | + else |
| 163 | + gh pr edit "$PR_NUMBER" \ |
| 164 | + --title "Update branch-alias to ${{ steps.check_alias.outputs.expected_alias }}" \ |
| 165 | + --body "$PR_BODY" \ |
| 166 | + --add-label "automated-pr" \ |
| 167 | + --base "${{ github.event.repository.default_branch }}" |
| 168 | + fi |
| 169 | + fi |
0 commit comments