-
-
Notifications
You must be signed in to change notification settings - Fork 2
63 lines (57 loc) · 1.98 KB
/
optimise-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Optimise Images
# **What it does**: Automatically compress and optimise images.
# **Why we have it**: Reduces bandwidth needs of app and repo.
on:
push:
branches:
- main
paths:
- "**.jpg"
- "**.jpeg"
- "**.png"
- "**.webp"
pull_request:
paths:
- "**.jpg"
- "**.jpeg"
- "**.png"
- "**.webp"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
build:
name: Optimise Images
runs-on: ubuntu-latest
# Only run on main repo and PRs that match the main repo
if: >
github.repository == 'Fdawgs/docsmith' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Compress images
id: calibre
uses: calibreapp/[email protected]
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
jpegQuality: "100"
pngQuality: "100"
webpQuality: "100"
# For non-Pull Requests, run in compressOnly mode and PR after
compressOnly: ${{ github.event_name != 'pull_request' }}
- name: Create pull request
# If it is not a Pull Request then commit any changes as a new PR
if: >
github.event_name != 'pull_request' &&
steps.calibre.outputs.markdown != ''
uses: peter-evans/create-pull-request@v7
with:
title: "chore: auto-compress images"
branch-suffix: timestamp
commit-message: "chore: auto-compress images"
body: ${{ steps.calibre.outputs.markdown }}