-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature / idea: allow to use as a gating action (fail on non-compressed images) #61
Comments
@ahmadnassri, this sounds like a helpful and useful addition, but at the moment a change like this would represent a pretty significant change to image-actions. We've some ideas for alternative run modes and configurable options, but without some work there, we're a while away from being able to add such a feature. |
@benschwarz this could be an alternative way to handle forks, if people didn't want to merge uncompressed images followed by a PR to compress them like I added in #54 In fact you could do this after #54 is released with something like this: name: Compress images
on:
pull_request:
# Run image-actions when jpg, jpeg, png or webp files are added or changed
# See https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onpushpull_requestpaths
paths:
- "**.jpg"
- "**.jpeg"
- "**.png"
- "**.webp"
jobs:
build:
name: calibreapp/image-actions
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Compress Images
uses: calibreapp/image-actions@master
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
compressOnly: true
- name: Comment on PR if branch contains uncompressed images
uses: actions/[email protected]
if: steps.calibre.outputs.markdown != ""
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
github.issues.createComment({ issue_number, owner, repo, body: 'Warning: Images not compressed.' }); We could also fail the Action in case a comment is missed which is probably better. Imagine this would be fairly easy with one new option ( |
Actually, thinking about this some more, you could do this already with the following workflow: name: Check Images are Compressed
on:
pull_request:
# Run image-actions when jpg, jpeg, png or webp files are added or changed
paths:
- "**.jpg"
- "**.jpeg"
- "**.png"
- "**.webp"
jobs:
build:
name: calibreapp/image-actions
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Compress Images
uses: calibreapp/image-actions@master
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
compressOnly: true
- name: Fail If Uncompressed Images Exist
if: steps.calibre.outputs.markdown != ""
run: exit 1 Not so sure it's necessary (or even a good idea) to actually add this to the Calibre code further than this, but probably would want to be able to specify the |
What:
allow flags to exit as failure if the found images compress at a higher level than the declared threshold, thus indicating that the committed images were not pre-optimized.
Why:
How:
run-as-test
(or better wording) which exists with a failure signal if the resulting compression is bigger than the defined quality settingThe text was updated successfully, but these errors were encountered: