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

Override option to set all Filters to true #204

Open
TooManyCarbs opened this issue Oct 23, 2023 · 2 comments
Open

Override option to set all Filters to true #204

TooManyCarbs opened this issue Oct 23, 2023 · 2 comments

Comments

@TooManyCarbs
Copy link

I am using a changes job to construct a list of lambda names which is passed to a lambda deployment job using a matrix strategy.

There are some cases where we would like to run all lambda deployments, regardless of whether or not they have changed. If there were an option to essentially mock as if all filters have detected changes, that would make this scenario very easy to deal with.

Is there a way to do this? Grateful for any advice.

@hilja
Copy link

hilja commented Feb 26, 2024

It would be nice if we could append a string in the commit message to skip all check. e.g. [skip changed check], or with a trailer skip-changed-check: true etc.

This is handy when tweaking CI.

@hilja
Copy link

hilja commented Feb 27, 2024

Turns this was easy to implement, I had no idea you get access to the commit message from the github context: github.event.head_commit.message.

This example uses [skip checks], add it somewhere in the last commit message.

Something like this:

skipChanges:
  name: ⏭️ Skip changes check
  runs-on: ubuntu-22.04
  outputs:
    isSkip: ${{ steps.skip.outputs.skip }}
  steps:
    - id: skip
      run: |
        echo "skip=$(echo ${{ contains(github.event.head_commit.message, '[skip checks]') }})" >> $GITHUB_OUTPUT

changes:
  name: 🗂️ Check changed files
  runs-on: ubuntu-22.04
  needs: skipChanges
  # Add it in the condition
  outputs:
    foo:
      ${{ needs.skipChanges.outputs.isSkip && 'true' || steps.filter.outputs.foo }}
  steps:
    - uses: actions/checkout@v4.1.1
      with:
        fetch-depth: 20
    - uses: dorny/paths-filter@v3
      id: filter
      with:
        base: ${{ github.ref }}
        filters: |
          foo:
            - 'foo/**/*.(ts|tsx)'

# Use `needs.changes.outputs` like you would normally
typecheck:
  name: Typecheck foo
  needs: changes
  if: ${{ needs.changes.outputs.foo == 'true' }}
  runs-on: ubuntu-22.04
  steps:
    - uses: actions/checkout@v4.1.1
    - uses: wyvox/action-setup-pnpm@v3
      with:
        args: '-F=foo'
    - run: pnpm -F=foo run typecheck

That checks the latest commit but you can check all commits too:

contains(join(github.event.commits.*.message, ' '), '[skip checks]')

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

No branches or pull requests

2 participants