Auto merge mod branches #43440
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto merge mod branches | |
| on: | |
| schedule: | |
| - cron: '0,10,20,30,40,50 * * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| PR_CLI_VERSION: '0.2.4' | |
| jobs: | |
| merge: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| error_message: ${{ steps.auto_merge.outputs.error_message}} | |
| steps: | |
| - name: Auto merge | |
| id: auto_merge | |
| run: | | |
| curl -L https://github.com/k-kinzal/pr/releases/download/v${{ env.PR_CLI_VERSION }}/pr_linux_amd64.tar.gz | tar xz | |
| ./pr --version | |
| echo "" | |
| exit_code=0 | |
| ./pr merge chatwork/dockerfiles --exit-code --with-statuses --with-checks \ | |
| -l 'state == `"open"`' \ | |
| -l 'base.ref == `"master"`' \ | |
| -l 'starts_with(head.ref, `"mod-up-"`)' \ | |
| -l 'user.login == `"cw-circleci"`' \ | |
| -l 'length(checks[?name == `"test (ubuntu-latest, linux/amd64)"` && status == `"completed"` && conclusion == `"success"`]) == `1`' \ | |
| -l 'length(checks[?name == `"test (ubuntu-24.04-arm, linux/arm64)"` && status == `"completed"` && conclusion == `"success"`]) == `1`' 2> ./error.log || exit_code=$? | |
| if [ $exit_code -eq 127 ]; then | |
| echo "No PRs to merge at this time." | |
| elif [ $exit_code -ne 0 ]; then | |
| echo "Auto merge failed with error (exit code $exit_code):" | |
| cat ./error.log | |
| echo "error_message=$(cat ./error.log)" >> "$GITHUB_OUTPUT" | |
| exit 1 | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.SELF_GITHUB_TOKEN }} | |
| notify: | |
| needs: merge | |
| runs-on: ubuntu-latest | |
| if: failure() | |
| steps: | |
| - name: Notification failed | |
| run: | | |
| TITLE="Github Actions: Failed auto merge (devil)" | |
| BODY="${{ needs.merge.outputs.error_message }}" | |
| GITHUB_JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
| curl -sS -X POST -H "X-ChatWorkToken: ${{ secrets.CHATWORK_API_TOKEN }}" \ | |
| "https://api.chatwork.com/v2/rooms/${{ secrets.CHATWORK_NOTIFICATION_ROOM_ID }}/messages" \ | |
| --data-urlencode "body=[info][title]${TITLE}[/title]${BODY}[hr]${GITHUB_JOB_URL}[/info]" |