Skip to content

Commit

Permalink
Update detect translation conflicts action (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
Furrior authored Aug 15, 2024
1 parent 285ada9 commit 5e50d8f
Showing 1 changed file with 43 additions and 13 deletions.
56 changes: 43 additions & 13 deletions .github/workflows/detect_translate_conflicts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
run: |
git config --local user.email "[email protected]"
git config --local user.name "SS220Manager"
git config --local merge.conflictStyle zdiff3
- name: Try merging
continue-on-error: true
run: |
Expand All @@ -28,26 +29,55 @@ jobs:
{
echo "MERGE_CONFLICTS<<EOF"
git diff --name-only --diff-filter=U | while read file; do
echo "- $file"
echo "<details>"
echo "<summary>$file</summary>"
echo -e "\n\`\`\`diff"
git diff --diff-filter=U "$file" | sed -n '/<<<<<<</,/>>>>>>>/p'
echo -e "\n\`\`\`"
echo "</details>"
done
echo EOF
} >> $GITHUB_ENV
- name: Run script
uses: actions/github-script@v7
with:
script: |
const { MERGE_CONFLICTS } = process.env
if(!MERGE_CONFLICTS) {
return
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `This pr causes following conflicts on translate branch:\n ${MERGE_CONFLICTS} `
})
const { MERGE_CONFLICTS } = process.env;
const conflict_message_header = "This PR causes following conflicts on translate branch:\n";
const issue_body = `${conflict_message_header}${MERGE_CONFLICTS}`;
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const action_comment = comments.data.find(comment => comment.body.startsWith(conflict_message_header) && comment.user.login === "github-actions[bot]");
if (action_comment) {
const comment_id = action_comment.id;
if (!MERGE_CONFLICTS) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment_id,
});
return;
}
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment_id,
body: issue_body,
});
} else if (MERGE_CONFLICTS) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: issue_body,
});
}

0 comments on commit 5e50d8f

Please sign in to comment.