You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-18Lines changed: 48 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,12 @@ Image Actions automatically compress JPEG, PNG and WebP images in GitHub Pull Re
8
8
- Runs in [GitHub Actions](https://github.com/features/actions)
9
9
- Built by web performance experts at [Calibre](https://calibreapp.com/); a performance monitoring platform
10
10
11
+
_image actions in action_
11
12

12
13
13
-
## Add Image Actions to your repository
14
+
## Installation
14
15
15
-
1. Open or create the `.github/workflows/calibreapp-image-actions.yml` file.
16
-
2. Paste in the following:
16
+
Create the `.github/workflows/calibreapp-image-actions.yml` file with the following configuration
17
17
18
18
```yml
19
19
name: Compress images
@@ -32,16 +32,14 @@ jobs:
32
32
githubToken: ${{ secrets.GITHUB_TOKEN }}
33
33
```
34
34
35
-
The`GITHUB_TOKEN` secret is [automatically generated by GitHub](https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret). This automatic token is [scoped only to the repository that is currently running the action.](https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions)
35
+
_The`GITHUB_TOKEN` secret is [automatically generated by GitHub](https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret). This automatic token is [scoped only to the repository that is currently running the action.](https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions)_
36
36
37
-
## Configure Image Actions
37
+
## Configuration
38
38
39
-
By default, you probably don’t need to configure `image-actions`.
40
-
However, if you’d like to ignore specific file paths, or change image compression options, read on.
41
-
42
-
Change the configuration options by adding arguments to the action:
39
+
### Default Settings
43
40
44
41
```yml
42
+
...
45
43
- name: Compress Images
46
44
uses: calibreapp/image-actions@master
47
45
with:
@@ -53,28 +51,60 @@ Change the configuration options by adding arguments to the action:
53
51
# No spaces allowed
54
52
```
55
53
56
-
Previous versions of image-actions used `.github/config/image-actions.yml` for configuration.
57
-
If you're still using that configuration method we suggest that you update it.
54
+
If you would like to modify the defaults, update the `.github/workflows/calibreapp-image-actions.yml` file by adding arguments to the action:
55
+
56
+
- [jpegQuality](http://sharp.pixelplumbing.com/en/stable/api-output/#jpeg): Number, integer 1-100, default 80 stroed in a string
57
+
- [pngQuality](http://sharp.pixelplumbing.com/en/stable/api-output/#png): Number, integer 1-100, default 80 stored in a string
58
+
- [webpQuality](http://sharp.pixelplumbing.com/en/stable/api-output/#webp): Number, integer 1-100, default 80 stored in a string
59
+
- `ignorePaths`: a comma separated string with [globbing](https://www.npmjs.com/package/glob) support of paths to ignore when looking for images to compress
60
+
61
+
_The `jpegQuality`, `pngQuality` and `webpQuality` config keys will be delivered directly into [sharp’s](http://sharp.pixelplumbing.com) `toFormat` method._
58
62
59
-
- The above configuration is what `image-actions` uses by default
60
-
- The `jpegQuality`, `pngQuality` and `webpQuality` config keys will be delivered directly into [sharp’s](http://sharp.pixelplumbing.com) `toFormat`. ([JPEG options](http://sharp.pixelplumbing.com/en/stable/api-output/#jpeg), [PNG options](http://sharp.pixelplumbing.com/en/stable/api-output/#png), [Webp options](http://sharp.pixelplumbing.com/en/stable/api-output/#webp))
61
-
- `ignorePaths`allows for path globbing [see the glob package for more details](https://www.npmjs.com/package/glob)
63
+
Previous versions of image-actions used `.github/calibre/image-actions.yml` for configuration. We suggest that you migrate to the newest configuration format by reading the [migration steps](#migration-legacy-configuration) below.
62
64
63
-
## Running the action only when images are changed
65
+
### Running the action only when images are changed
64
66
65
-
`image-actions`is designed to run for each Pull Request. In some repositories, images are seldom updated. To run the action only when images have changed, use GitHub Action’s [`on.push.paths`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onpushpull_requestpaths) workflow configuration:
67
+
image-actions is designed to run for each Pull Request. In some repositories, images are seldom updated. To run the action only when images have changed, use GitHub Action’s [`on.push.paths`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onpushpull_requestpaths) workflow configuration:
66
68
67
69
```yml
68
70
name: Compress images
69
-
on:
71
+
on:
70
72
pull_request:
71
73
paths:
72
74
- '**.jpg'
73
75
- '**.png'
74
76
- '**.webp'
75
77
```
76
78
77
-
The above workflow will only run when `jpg`, `png` or `webp` files are changed.
79
+
The above workflow will only run on a pull request when `jpg`, `png` or `webp` files are changed.
80
+
81
+
## Migrate legacy configuration
82
+
83
+
- uses: docker://calibreapp/github-image-actions
84
+
85
+
If your calibreapp-image-actions.yml file has a reference to `docker://` or `GITHUB_TOKEN` like below
86
+
87
+
```yml
88
+
- name: calibreapp/image-actions
89
+
uses: docker://calibreapp/github-image-actions
90
+
env:
91
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92
+
```
93
+
94
+
Update your configuration to match the following
95
+
96
+
```yml
97
+
- name: Compress images
98
+
uses: calibreapp/image-actions@master
99
+
with:
100
+
githubToken: ${{ secrets.GITHUB_TOKEN }}
101
+
```
102
+
103
+
- `.github/calibre/image-actions.yml`
104
+
105
+
If your repository uses `.github/calibre/image-actions.yml` for configuration, it should be moved into `.github/workflows/calibreapp-image-actions.yml`. Then delete the `image-actions.yml` file.
106
+
107
+
`ignorePaths` is no longer an array and is now a comma separated list. eg: `ignorePaths: "node_modules/**,bin"`
0 commit comments