Shopify / theme-check-action

Run shopify/theme-check on GitHub pull requests
Other
38 stars 14 forks source link

How to run only on a pull request instead of all push events? #46

Closed binarymonkey84 closed 2 months ago

binarymonkey84 commented 2 months ago

I tried setting up the action with on: pull_request instead of on: [push], but this doesn't appear to work.

I was expecting that to work since the action is described as being for checking code on pull requests.

I can't really have this running on every push event for every branch, since we are using Shopify Github Integration. This integration pushes commits when a merchant changes anything in Theme Customiser. That means multiple daily pushes, and we don't need Theme Check running on those.

Is this a known issue or am I doing something wrong here?

As a workaround I've used the below configuration to avoid the action running on my main branch, but there are other branches we want to exclude as well, and I'd rather not have to explicitly define every branch individually for every repo we're working on. It would be far simpler to just work on the pull_request event, as that would require no repo-specific configuration.

name: Theme Check
on:
  push:
    branches-ignore:
      - main
jobs:
  theme-check:
    name: Theme Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Theme Check
        uses: shopify/theme-check-action@v2
        with:
          theme_root: '.' # optional, could be './dist'
          token: ${{ github.token }}
          base: main
karreiro commented 2 months ago

Thank you for raising this issue, @binarymonkey84! I've managed to get Theme Check running on PRs with the following configuration:

name: CI Build and Test

on:
  pull_request:
    types: [ opened ]
    branches: [ main ]

jobs:
  theme-check:
    name: Theme Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Theme Check
        uses: shopify/theme-check-action@v2

Please let me know if we've missed anything tho! Thanks again for bringing reporting this :)