mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04:00
Update uncivbot.yml
This commit is contained in:
parent
9d7e6d1310
commit
c1b9fc677d
39
.github/workflows/uncivbot.yml
vendored
39
.github/workflows/uncivbot.yml
vendored
@ -4,16 +4,43 @@ on: [issue_comment]
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
if: github.event.comment.body == 'summary'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/github-script@v3
|
||||
if: github.event.comment.body == 'summary'
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
github.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: "${{ github.event.comment.body }}"
|
||||
var result = await context.github.repos.listCommits(context.repo({ per_page: 50 }));
|
||||
var commitSummary = "";
|
||||
var ownerToCommits = {}
|
||||
var reachedPreviousVersion = false
|
||||
result.data.forEach(commit => {
|
||||
if(reachedPreviousVersion) return
|
||||
var author = commit.author.login
|
||||
if(author=="uncivbot[bot]") return
|
||||
var commitMessage = commit.commit.message.split("\n")[0];
|
||||
if(commitMessage.match(/^\d+\.\d+\.\d+$/)){ // match EXACT version, like 3.4.55 ^ is for start-of-line, $ for end-of-line
|
||||
reachedPreviousVersion=true
|
||||
console.log(commitMessage)
|
||||
return
|
||||
}
|
||||
if(commitMessage.startsWith("Merge ")) return
|
||||
commitMessage = commitMessage.replace(/\(\#\d+\)/,"") // match PR auto-text, like (#2345)
|
||||
if (author != owner){
|
||||
if (ownerToCommits.get(author)==undefined) ownerToCommits.set(author,[])
|
||||
ownerToCommits.get(author)?.push(commitMessage)
|
||||
}
|
||||
else commitSummary += "\n\n" + commitMessage
|
||||
});
|
||||
ownerToCommits.forEach((commits,author)=>{
|
||||
commitSummary += "\n\nBy "+author+":"
|
||||
commits.forEach(commitMessage => {commitSummary+="\n- "+commitMessage})
|
||||
})
|
||||
context.github.issues.createComment(context.issue({ body: commitSummary }));
|
||||
//github.issues.createComment({
|
||||
// issue_number: context.issue.number,
|
||||
// owner: context.repo.owner,
|
||||
// repo: context.repo.repo,
|
||||
// body: "${{ github.event.comment.body }}"
|
||||
//})
|
||||
|
Loading…
x
Reference in New Issue
Block a user