Skip to content

Commit

Permalink
Add workflow to check git conflict for backport PR (#2548) (#2550)
Browse files Browse the repository at this point in the history
* feat: add workflow to check conflict



* Apply suggestions from code review



* feat: send conflict warning comment



* fix: verify for sending comment



* style: format code with Gofumpt and Prettier

This commit fixes the style issues introduced in aee3f32 according to the output
from Gofumpt and Prettier.

Details: #2548

* fix: verify for sending comment



* fix: debug body



* fix: add log



* feat: add debug code



* fix: add debug



* fix: deleted unnecessary debug code



* fix: fails comment for sending comment



* fix: deleted unnecessary changes



* feat: fix grep condition



* fix: add changes for verify



* Revert "fix: add changes for verify"

This reverts commit 98f4c44.

* fix: add changes for verify



* Revert "fix: add changes for verify"

This reverts commit 31ed2a8.

---------

Signed-off-by: hlts2 <[email protected]>
Signed-off-by: Yusuke Kato <[email protected]>
Co-authored-by: Hiroto Funakoshi <[email protected]>
Co-authored-by: Yusuke Kato <[email protected]>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jul 30, 2024
1 parent bc93d26 commit b9befd9
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/check-conflict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Check conflict
on:
pull_request:
jobs:
dump-contexts-to-log:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/dump-context
check-conflict:
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.DISPATCH_TOKEN }}
- name: Set Git config
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Check conflict
run: |
if grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then
PR_COMMENTS=`curl ${API_URL}?per_page=10000`
BODY=`echo -E "${PR_COMMENTS}" | jq 'last(.[] | select(.user.login == "vdaas-ci") | select(.body | test("^\\\\*\\\\*\\\\[WARNING:CONFLICT")) | .body)' -r`
if [ "${BODY}" = "null" ]; then
curl --include --verbose --fail \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
--request POST \
--data "{\"body\": \"**[WARNING:CONFLICT]** You may require to fix the conflict. Please check.\"}" \
${API_URL}
fi
echo "Please fix conflict locally."
exit 1
else
echo "Nothing conflict"
fi
env:
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
API_URL: ${{ github.event.pull_request.comments_url }}

0 comments on commit b9befd9

Please sign in to comment.