Skip to content

Detecting changes against main branch on main branch merge? #201

Open
@ScottPierce

Description

@ScottPierce

I'm trying to detect changes on the main branch when merging a PR into the main branch. I kept on getting

Error: The process '/usr/bin/git' failed with exit code 128

I've solved it by

  1. Checking out the repository beforehand
  2. Manually grabbing the previous commit sha and saving it to an environment variable
  3. Using the commit sha as a base for the query.

Surely I'm over complicating this, and there is a simpler way to do this?

on:
  push:
    branches:
      - main
  workflow_dispatch:
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          ref: ${{ github.ref }}
          fetch-depth: 2

      - name: Get previous commit SHA
        id: prev_commit
        run: echo "PREV_COMMIT_SHA=$(git rev-parse HEAD~1)" >> $GITHUB_ENV

      - uses: dorny/paths-filter@v2
        id: filter
        with:
          base: ${{ env.PREV_COMMIT_SHA }}
          filters: |
            changed:
              - 'example**'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions