From d030ce7182dadb444e1735b4b91170e2d0906277 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 8 Mar 2022 20:28:14 +0200 Subject: [PATCH] Updates summary action to use node.js script --- .github/workflows/uncivbot.yml | 47 +++------------------------------- 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/.github/workflows/uncivbot.yml b/.github/workflows/uncivbot.yml index 3d08401ab0..cf927a42de 100644 --- a/.github/workflows/uncivbot.yml +++ b/.github/workflows/uncivbot.yml @@ -155,50 +155,9 @@ jobs: # This is the only place I could find an apparent list of valid author associations. Also, at least they're not case-sensitive: https://docs.github.com/en/graphql/reference/enums#commentauthorassociation https://docs.github.com/en/actions/learn-github-actions/expressions#contains runs-on: ubuntu-latest steps: - - uses: actions/github-script@v3 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - var result = await github.repos.listCommits({ - owner: context.repo.owner, - repo: context.repo.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 ") || commitMessage.startsWith("Update ")) return - commitMessage = commitMessage.replace(/\(\#\d+\)/,"") // match PR auto-text, like (#2345) - if (author != context.repo.owner){ - if (ownerToCommits[author] == undefined) ownerToCommits[author]=[] - ownerToCommits[author].push(commitMessage) - } - else commitSummary += "\n\n" + commitMessage - }); - Object.entries(ownerToCommits).forEach(entry => { - const [author, commits] = entry; - if (commits.length==1) commitSummary += "\n\n" + commits[0] + " - By "+author - else { - commitSummary += "\n\nBy "+author+":" - commits.forEach(commitMessage => { commitSummary += "\n- "+commitMessage }) - } - }) - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: commitSummary - }) + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + - run: node .github/workflows/createChangelogEntry.js ${{ secrets.ACTIONS_ACCESS_TOKEN }} merge_translations: if: github.event_name == 'workflow_dispatch' || (github.event.comment.body == 'merge translations' && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))