name: If files in folder_path were changed
on:
push:
jobs:
if-file-changed:
name: Check if files changed
runs-on: ubuntu-latest
steps:
- name: Get files changed on push
run: |
echo ${{ github.sha }} - commit sha that triggered this workflow
echo ${{ github.event.before }} - previous sha
git --no-pager diff --name-only ${{ github.sha }} ${{ github.event.before }}
I get error – error: Could not access 'oaisjdoiasjdoaijsd12319023'
I am trying to get diff between 2 commit SHA’s
The same command works fine when I run from local machine :
git --no-pager diff --name-only aosdiasodi oaisdoaisjd
2
Answers
order of sha's in question is wrong . correct order is -
But this wont work if you force push a commit because in that case the previous commit was overwritten hence rendered invalid.
Refer to gha-files-changed Github repo that implements this functionality
I think you should clone the repo bifore exec some local
git
command, so try this:See https://github.com/actions/checkout