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

[QUESTION] workflow_dispatch only getting the last 2 #2285

Closed
4 tasks done
omri-shilton opened this issue Sep 18, 2024 · 3 comments
Closed
4 tasks done

[QUESTION] workflow_dispatch only getting the last 2 #2285

omri-shilton opened this issue Sep 18, 2024 · 3 comments
Labels
question Further information is requested

Comments

@omri-shilton
Copy link

omri-shilton commented Sep 18, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

When using workflow dispatch on a branch the diff between commits is only the last two commits in the branch instead of the base branch.
My use case is when im developing in a branch before doing a pull_request.
I may be missing something, im not sure.

To Reproduce

  1. create a development branch
  2. change files
  3. manually run the workflow using github actions UI
  4. see that the diff is only from the last two commits instead of from the base branch i came out of.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-22.04

Expected behavior?

I would assume that the diff would be from the base branch i came out of.

Relevant log output

Using local .git directory
  Running on a workflow_dispatch event...
  Retrieving changes between 6ac698bd2f5e4fd889f13f38add131427a5e9e3d (webapps-changed-files) → 39ddd7daed23f932527a56085cf893123d1c499b (webapps-changed-files)
  All Done!
changed-files-patterns
  All Done!

Has all relevant logs been included?

  • I've included all relevant logs

Anything else?

not that i think its relevant, im using self hosted runners.
this is my action code

  changed-dirs:
    runs-on: custom-runner-2
    outputs:
      matrix: ${{ steps.changed-dirs.outputs.all_changed_files }}
    steps:
      - name: Install git
        run: |
          sudo apt-get update && sudo apt-get install -y jq git git-lfs

      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-dirs
        uses: tj-actions/changed-files@v45
        with:
          matrix: true
          dir_names: true
          files: "backend/webapps/**"

Code of Conduct

  • I agree to follow this project's Code of Conduct
@omri-shilton omri-shilton added the bug Something isn't working label Sep 18, 2024
@tj-actions-bot
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Sep 18, 2024

Hi @omri-shilton, for workflow_dispatch event the GitHub context value for the last commit of the base branch used for comparison github.event.pull_request.base.sha is unset since this is limited to only pull requests events as such you’ll need to provide the base_sha via the input which can be the git sha of the last commit of the base branch or just the base branch name.

Example

  changed-dirs:
    runs-on: custom-runner-2
    outputs:
      matrix: ${{ steps.changed-dirs.outputs.all_changed_files }}
    steps:
      - name: Install git
        run: |
          sudo apt-get update && sudo apt-get install -y jq git git-lfs

      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-dirs
        uses: tj-actions/changed-files@v45
        with:
          matrix: true
          dir_names: true
          files: "backend/webapps/**"
          base_sha: main  # <- Add the target branch name here

@jackton1 jackton1 added question Further information is requested and removed bug Something isn't working labels Sep 18, 2024
@jackton1 jackton1 changed the title [BUG] workflow_dispatch only getting the last 2 commits [QUESTION] workflow_dispatch only getting the last 2 Sep 18, 2024
@omri-shilton
Copy link
Author

Hi @omri-shilton, for workflow_dispatch event the GitHub context value for the last commit of the base branch used for comparison github.event.pull_request.base.sha is unset since this is limited to only pull requests events as such you’ll need to provide the base_sha via the input which can be the git sha of the last commit of the base branch or just the base branch name.

Example

  changed-dirs:
    runs-on: custom-runner-2
    outputs:
      matrix: ${{ steps.changed-dirs.outputs.all_changed_files }}
    steps:
      - name: Install git
        run: |
          sudo apt-get update && sudo apt-get install -y jq git git-lfs

      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-dirs
        uses: tj-actions/changed-files@v45
        with:
          matrix: true
          dir_names: true
          files: "backend/webapps/**"
          base_sha: main  # <- Add the target branch name here

Thanks!

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

No branches or pull requests

3 participants