Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to determine changes since "last successful build" #80

Closed
tricky42 opened this issue Apr 7, 2021 · 2 comments
Closed

How to determine changes since "last successful build" #80

tricky42 opened this issue Apr 7, 2021 · 2 comments

Comments

@tricky42
Copy link

tricky42 commented Apr 7, 2021

I am looking into how I can build a Github Actions Pipeline for a Monorepo using paths-filters.
paths-filters ensures that only the needed Jobs are executed and this works good for PRs / feature branches. As part of the pipeline we run tests on branches and prs. Once a change gets merged into master branch we run a couple of more tests before the changes are deployed to our staging system. This works fine if tests are not failing ;) but in case e.g. some tests fail I would like to somehow with the next run take all changes since the last "successful" commit to master into account.
Technically I can do it by using the commit SHA of the last successful commit as the base. But then I would have to change my workflow yaml once tests finish successfully, which doesnt sound like a good idea.

Any other ideas how to solve this?

Thanks for this great Github Actions ;)

@dorny
Copy link
Owner

dorny commented Apr 7, 2021

GitHub provides API to list workflow runs and you can filter them by workflow ID and status. Here are the docs.
Using it to get SHA of last successful run is quite simple. However I would say this is a better fit for a standalone action rather then integrating it directly into paths-filter.

Looks like somebody already made it: last-successful-commit-action.
I didn't test it but the code seems to be doing exactly what you want.
You could then use output of last-successful-commit-action as base input parameter in paths-filter.

Another possible solution would be to maintain a branch or tag pointing to last successful commit. You could have a step in your pipeline which would update it after successful test execution or deployment. paths-filter would then use it as a base instead of master.

@tricky42
Copy link
Author

tricky42 commented Apr 8, 2021

Thanks for the quick feedback. This was exactly what I was looking for, sorry for using you as a Google Proxy ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants