Skip to content

Commit 737ceea

Browse files
authored
Merge pull request #45 from steveoh/patch-1
docs: clarify the docs
2 parents fe910a9 + c2f1618 commit 737ceea

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

README.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ Image Actions automatically compress JPEG, PNG and WebP images in GitHub Pull Re
88
- Runs in [GitHub Actions](https://github.com/features/actions)
99
- Built by web performance experts at [Calibre](https://calibreapp.com/); a performance monitoring platform
1010

11+
_image actions in action_
1112
![Preview of image-actions Pull Request comment](https://user-images.githubusercontent.com/924/62024579-e1470d00-b218-11e9-8655-693ea42ba0f7.png)
1213

13-
## Add Image Actions to your repository
14+
## Installation
1415

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
1717

1818
```yml
1919
name: Compress images
@@ -32,16 +32,14 @@ jobs:
3232
githubToken: ${{ secrets.GITHUB_TOKEN }}
3333
```
3434
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)_
3636

37-
## Configure Image Actions
37+
## Configuration
3838

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
4340

4441
```yml
42+
...
4543
- name: Compress Images
4644
uses: calibreapp/image-actions@master
4745
with:
@@ -53,28 +51,60 @@ Change the configuration options by adding arguments to the action:
5351
# No spaces allowed
5452
```
5553

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._
5862

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.
6264

63-
## Running the action only when images are changed
65+
### Running the action only when images are changed
6466

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:
6668

6769
```yml
6870
name: Compress images
69-
on:
71+
on:
7072
pull_request:
7173
paths:
7274
- '**.jpg'
7375
- '**.png'
7476
- '**.webp'
7577
```
7678

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"`
78108

79109
## Links and Resources
80110

0 commit comments

Comments
 (0)