Skip to content

Commit

Permalink
Update Compress Images GitHub Actions workflow (#4478)
Browse files Browse the repository at this point in the history
The Compress Images workflow isn't catching most of the images being
committed. This is, in part, because it doesn't run with permissions to
edit PRs on forks.  This updates the configuration to open a new PR when
a commit is merged, if there are images that can be compressed. It also
adds a scheduled run, in case something gets missed.
Based on https://github.com/calibreapp/image-actions#combined-workflow
  • Loading branch information
bdukes authored Mar 2, 2021
1 parent 1017dad commit ec762ba
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion .github/workflows/image-actions.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
name: Compress images
on: pull_request
on:
pull_request: # PRs with image (but we can't push changes back to other forks)
paths:
- "**.jpg"
- "**.jpeg"
- "**.png"
- "**.webp"
push:
branches:
- development # merging PRs from other forks (will open a new PR)
worflow_dispatch: # on demand
schedule:
- cron: "0 0 * * 0" # every Sunday at midnight
jobs:
build:
if: | # Only run on main repo on and PRs that match the main repo.
github.repository == 'dnnsoftware/Dnn.Platform' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
name: calibreapp/image-actions
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Compress Images
id: compress_images
uses: calibreapp/[email protected]
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
compressOnly: ${{ github.event_name != 'pull_request' }} # For non-Pull Requests, run in compressOnly mode and we'll PR after.

- name: Create Pull Request
if: | # If it's not a Pull Request then commit any changes as a new PR.
github.event_name != 'pull_request' && steps.compress_images.outputs.markdown != ''
uses: peter-evans/create-pull-request@v3
with:
title: Auto Compress Images
branch-suffix: timestamp
commit-message: Compress Images
body: ${{ steps.compress_images.outputs.markdown }}

0 comments on commit ec762ba

Please sign in to comment.