Skip to content

Commit

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

Signed-off-by: hlts2 <[email protected]>

* Apply suggestions from code review

Signed-off-by: Yusuke Kato <[email protected]>

* feat: send conflict warning comment

Signed-off-by: hlts2 <[email protected]>

* fix: verify for sending comment

Signed-off-by: hlts2 <[email protected]>

* 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

Signed-off-by: hlts2 <[email protected]>

* fix: debug body

Signed-off-by: hlts2 <[email protected]>

* fix: add log

Signed-off-by: hlts2 <[email protected]>

* feat: add debug code

Signed-off-by: hlts2 <[email protected]>

* fix: add debug

Signed-off-by: hlts2 <[email protected]>

* fix: deleted unnecessary debug code

Signed-off-by: hlts2 <[email protected]>

* fix: fails comment for sending comment

Signed-off-by: hlts2 <[email protected]>

* fix: deleted unnecessary changes

Signed-off-by: hlts2 <[email protected]>

* feat: fix grep condition

Signed-off-by: hlts2 <[email protected]>

* fix: add changes for verify

Signed-off-by: hlts2 <[email protected]>

* Revert "fix: add changes for verify"

This reverts commit 98f4c44.

* fix: add changes for verify

Signed-off-by: hlts2 <[email protected]>

* 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: Yusuke Kato <[email protected]>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 30, 2024
1 parent caa8f03 commit 226fb39
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 226fb39

Please sign in to comment.