From d9e2ada3690ff4e3abb86c2b1ea7e2030decae80 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Sat, 15 Jul 2023 02:01:11 +0200 Subject: [PATCH] Minimize images in PR descriptions --- .github/workflows/image-minimizer.js | 10 ++++++++++ .github/workflows/image-minimizer.yml | 2 ++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/image-minimizer.js b/.github/workflows/image-minimizer.js index 5fbd1f3b8..d3532ad83 100644 --- a/.github/workflows/image-minimizer.js +++ b/.github/workflows/image-minimizer.js @@ -17,6 +17,8 @@ module.exports = async ({github, context}) => { initialBody = context.payload.comment.body; } else if (context.eventName == 'issues') { initialBody = context.payload.issue.body; + } else if (context.eventName == 'pull_request') { + initialBody = context.payload.pull_request.body; } else { console.log('Aborting: No body found'); return; @@ -74,6 +76,14 @@ module.exports = async ({github, context}) => { repo: context.repo.repo, body: newBody }); + } else if (context.eventName == 'pull_request') { + console.log('Updating pull request', context.payload.pull_request.number); + await github.rest.pulls.update({ + pull_number: context.payload.pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: newBody + }); } // Asnyc replace function from https://stackoverflow.com/a/48032528 diff --git a/.github/workflows/image-minimizer.yml b/.github/workflows/image-minimizer.yml index b8bf9e1d2..56c6eb37f 100644 --- a/.github/workflows/image-minimizer.yml +++ b/.github/workflows/image-minimizer.yml @@ -5,6 +5,8 @@ on: types: [created, edited] issues: types: [opened, edited] + pull_request: + types: [opened, edited] permissions: issues: write