0

I am trying to get last check-in files.

Requirement is user will check-in a configuration file and that config file will be passed to a script for execution. If there are 4 files checked-in then, I need to identify all 4 file and execute script in loop for each file.

I was able to do it using following steps:

  - name: checkout repo content
    uses: actions/checkout@v2
    with:
      fetch-depth: 2

  - name: Identify and execute different Configuration files
    run: |
      echo "Check-in configuration files are"
      files=$(git diff --name-only HEAD^..HEAD)

However this is causing one issue.

If user perform git add, git commit, git add, git commit and then git push It only pick file of last commit only.

I want file to be picked from last PUSH to recent PUSH.

Please suggest

Karki
  • 7
  • 4
  • 1
    Instead of `HEAD^` use `HEAD@{1}`. – jthill Mar 18 '23 at 21:36
  • Hi Jill, this didnt work. It rather give error – Karki Mar 19 '23 at 07:04
  • you say you use `github-actions`, correct ? on what events do you want to trigger your job ? one point you should address is "how do I spot the 'last state' of my branch ?" – LeGEC Mar 19 '23 at 10:59
  • I want job to be triggered on every push... It should check the new files which has been pushed and then run script for each pushed file – Karki Mar 20 '23 at 04:56
  • I find this link: https://github.com/tj-actions/changed-files/issues/234 But not sure how to get file name after this... Does anyone has any idea – Karki Mar 20 '23 at 05:30

0 Answers0