trilom / file-changes-action

This action can be added, and you will get outputs of all of the files that have changed in your repository for you to use.
MIT License
167 stars 48 forks source link

Changes relative to base branch #96

Open srolel opened 4 years ago

srolel commented 4 years ago

Is your feature request related to a problem? Please describe. I would like to lint only changed files, but lint them from the base branch.

Describe the solution you'd like Omit changes relative to base branch.

Describe alternatives you've considered Squashing when the action runs.

trilom commented 4 years ago

Hey @srolel -

I believe what you are talking about is covered here by providing a different pushBefore or pushAfter SHA, or a seperate prNumber.

Some ways I use this are in the lowest example on the readme where I use the head_commit.id from the commit to get the commit's PR number (merge request push) and get a list of files. You can then use that list to perform your action.

RayBB commented 2 years ago

The easiest way I've found to do this is in GitHub Actions use the pull_request event and prNumber: ${{ github.event.number }}

name: pre-commit
on:
  pull_request
jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
      with:
        python-version: 3.9
    - id: file_changes
      uses: trilom/file-changes-action@v1.2.4
      with:
        prNumber: ${{ github.event.number }}
        output: ' '
    - uses: pre-commit/action@v2.0.3
      name: mypy
      with: 
        extra_args: mypy --files ${{ steps.file_changes.outputs.files }}