-
I'd like to get changes pushed since the last successful workflow run on any given branch. Not sure if it's easily achievable? The general idea is that my app has frontend and backend code in the same repo and I only want to run (the 30+ min long) backend tests if the backend code has changed. Looking at the examples I'm guessing there'd be a problem if I just took the changes since the last push, since a run could fail or be canceled and then the subsequent run on the next push wouldn't see the changes from the previous push. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @depsypher, I believe this feature is highlighted in the example - name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
# To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g
with:
since_last_remote_commit: true In your case however I don’t think you’ll need to use this input because as you mentioned changes from recently pushed commits would not be compared when only comparing the last remote commit to the current one. You can use the defaults with pull_request events or optionally specify a Exampleon:
pull_requests:
branches:
- main
…
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40 |
Beta Was this translation helpful? Give feedback.
-
Thanks, ok yeah. We trigger on push rather than pull_request, not sure if that makes a difference. We deploy to a sandbox environment on pushes to the main branch (with successful workflow run i.e. all ci steps including tests pass). Likewise on pushes to a prod branch we deploy to production. In any case I guess I was hoping for a turn-key way of doing it without changing our workflow too much. The scenario I'm worrying about is:
Seems we'd have to keep track of the sha hash of the last successful workflow run on every branch that gets pushed and saving that state somewhere (external?) to be used as a base for the next comparison? Totally understandable if that's outside the scope of the action to keep track of, but just wanted to check if this was a common usecase and solved already. |
Beta Was this translation helpful? Give feedback.
Hi @depsypher, I believe this feature is highlighted in the example
In your case however I don’t think you’ll need to use this input because as you mentioned changes from recently pushed commits would not be compared when only comparing the last remote commit to the current one.
You can use the defaults with pull_request events or optionally specify a
base_sha
(supports branch or commit SHA) which would…