Skip to content
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

Use main branch from calibreapp/image-actions and run on schedule #1144

Open
wants to merge 2 commits into
base: release/v6.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions .github/workflows/calibreapp-image-actions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Image Actions will run in the following scenarios:
# - on Pull Requests containing images (not including forks)
# - on pushing of images to `main` (for forks)
# - on demand (https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/)
# - at 11 PM every Sunday in anything gets missed with any of the above scenarios
# For Pull Requests, the images are added to the PR.
# For other scenarios, a new PR will be opened if any images are compressed.
name: Compress Images

on:
Expand All @@ -7,18 +14,50 @@ on:
- '**.jpeg'
- '**.png'
- '**.webp'
push:
branches:
- master
paths:
- '**.jpg'
- '**.jpeg'
- '**.png'
- '**.webp'
workflow_dispatch:
schedule:
- cron: '00 23 * * 0'

jobs:
build:
# Only run on Pull Requests within the same repository, and not from forks.
if: github.event.pull_request.head.repo.full_name == github.repository
# The job needs to be able to pull the code and create a pull request.
permissions:
contents: read # for actions/checkout
pull-requests: write # to create pull request

name: calibreapp/image-actions
runs-on: ubuntu-latest

if: |
github.repository == 'pi-hole/docs' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)

steps:
- name: Checkout Repo
uses: actions/[email protected]

- name: Compress Images
uses: calibreapp/image-actions@1.1.0 # TODO: if they start using a tag like v1, switch to that
uses: calibreapp/image-actions@main # Their latest tag is > 4 years old and the README says to use main
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
# For non-Pull Requests, run in compressOnly mode and we'll PR after.
compressOnly: ${{ github.event_name != 'pull_request' }}

# If it's not a Pull Request then commit any changes as a new PR.
- name: Create Pull Request
if: |
github.event_name != 'pull_request' &&
steps.calibre.outputs.markdown != ''

run: gh pr create -B image_compress -H master --title 'Auto Compress Images' --body ${{ steps.calibre.outputs.markdown }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading