Skip to content

Commit

Permalink
Minimize images in PR descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Jul 15, 2023
1 parent 8cfba40 commit d9e2ada
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/image-minimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/image-minimizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
types: [created, edited]
issues:
types: [opened, edited]
pull_request:
types: [opened, edited]

permissions:
issues: write
Expand Down

0 comments on commit d9e2ada

Please sign in to comment.