Skip to content

How to compare with the main branch when a PR is created, and then with the last commit before a new push if the PR is already there? #2245

Answered by jackton1
rafrafek asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, @rafrafek. This is already supported, so you wouldn't need to calculate the BASE_SHA.

To accomplish this, you will need to set the input since_last_remote_commit to true.

name: ci

on:
  pull_request:
    branches:
      - main
    types:
      - opened
      - synchronize

permissions:
  contents: read
  packages: write

jobs:
  prepare:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.prepare.outputs.matrix }}
      length: ${{ steps.prepare.outputs.length }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v45

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@jackton1
Comment options

@rafrafek
Comment options

@jackton1
Comment options

@rafrafek
Comment options

@rafrafek
Comment options

Answer selected by jackton1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants