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

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

Open
carstingaxion opened this issue Sep 4, 2024 · 1 comment
Open

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

carstingaxion opened this issue Sep 4, 2024 · 1 comment

Comments

@carstingaxion
Copy link

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 "[email protected]"
    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.

@benschwarz
Copy link
Member

Hey @carstingaxion, apologies for the delay in getting back to you.

Looking at your configuration, two details pop out to me:

  1. Branch configuration restricts to running on branches named fix/screenshots-**. Is your PR using that branch pattern?
on:
  push:
    branches:
      - 'fix/screenshots-**'
  1. File matcher filtering restricts to running on PRs where image files have been edited. If you haven't added/edited/removed any jpg, webp, png etc, then this action won't run.
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'

To debug I would recommend altering both or either of these two blocks and experimenting with the results. On your PR you can click checks to see checks that were run or skipped for your PR. There's also a global repository actions view that might also be helpful to debug.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants