Hi I have Github Pages website and the images are giving bad performance reviews on Google Lighthouse due to their size but I don’t want to manually compress everything for every image I upload.
So I am using a Github Action to auto-compress every image I upload but it is not running and I do not know where I have gone wrong here. I will attempt to explain what I am doing in this snippet of code.
So this is the first snippet that came from the Calibre Image Actions. I wish I could somehow debug the action on Github as that’s where they tell you to create the Workflow.
I feel like I am missing something very simple. All I need was to ensure it runs on push. I notice the Github Token doesn’t need to be set manually on Github as it only runs when I enable Github Actions.
Except with me. Can anyone tell me what I am missing, please?
name: Compress Images
on:
push:
# 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 for reference.
paths:
- '**.jpg'
- '**.jpeg'
- '**.png'
- '**.webp'
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
name: calibreapp/image-actions
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Compress Images
uses: calibreapp/image-actions@main
with:
# The `GITHUB_TOKEN` is automatically generated by GitHub and scoped only to the repository that is currently running the action. By default, the action can’t update Pull Requests initiated from forked repositories.
# See https://docs.github.com/en/actions/reference/authentication-in-a-workflow and https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions
githubToken: ${{ secrets.GITHUB_TOKEN }}