Add: new NAS Trurl #1781
Workflow file for this run
This file contains 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: Detect translation conflicts | |
on: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
comment: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Fetch repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup git | |
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: | | |
git merge origin/translate | |
- name: Save merge results | |
run: | | |
{ | |
echo "MERGE_CONFLICTS<<EOF" | |
git diff --name-only --diff-filter=U | while read file; do | |
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; | |
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, | |
}); | |
} |