calibreapp / image-actions

A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
https://calibreapp.com/blog/compress-images-in-prs
GNU General Public License v3.0
1.42k stars 67 forks source link

Workflow is never triggered by "gh pr create" #282

Open carstingaxion opened 1 week ago

carstingaxion commented 1 week ago

Hello developers of this nice action!

May someone please have a look at this simplified setup and could tell me any reason, why it never triggers your workflow?!

In a first workflow, some images are created or updated. In that same workflow, this are last two steps, to commit and push the changes and create a PR out of it.

- name: Commit updated screenshots
  run: |
    git checkout -b fix/screenshots-${{ matrix.locale }}-${{ github.sha }}
    git config --local user.email "action@github.com"
    git config --local user.name "GitHub Action"
    git add -A
    git commit -m "Screenshots for ${{ matrix.locale }} updated!"
    git push origin fix/screenshots-${{ matrix.locale }}-${{ github.sha }}
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create a Pull Request
  # Using GitHub CLI in Workflows
  # https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows
  # https://cli.github.com/manual/gh_pr_create
  run: gh pr create -B main -H fix/screenshots-${{ matrix.locale }}-${{ github.sha }} --title 'Update ${{ matrix.locale }} screenshots for wordpress.org' --body 'Created with ❤️ by WordPress Playground, Playwright & GitHub action'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

While in a second worklfow, I've almost identical one of your workflow examples.

name: Compress Images
on:
  push:
    branches:
      - 'fix/screenshots-**'
  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 for reference.
    paths:
      - '**.jpg'
      - '**.jpeg'
      - '**.png'
      - '**.webp'
jobs:
  build:
    # Only run on Pull Requests within the same repository, and not from forks.
    # TEMP DISABLED TO TEST # if: github.event.pull_request.head.repo.full_name == github.repository
    name: calibreapp/image-actions
    permissions: write-all
    runs-on: ubuntu-latest
    steps:

      - name: Checkout Repo
        uses: actions/checkout@v4

      - name: Compress Images
        uses: calibreapp/image-actions@main #main is regularly updated (until 09/2024 so far), while the latest tagged version is from 2020
        with:
          # Configuration could be added
          # https://github.com/marketplace/actions/image-actions#%EF%B8%8F-configuration
          #
          # 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 }}

What could be the reason, this never starts?

Thanks for this great action & thanks in advance of your answer.