Issue
I have a yaml file for github action :
name : "Integration"
on :
push :
branches : [master]
jobs :
test-code :
runs-on : ubuntu-latest
steps :
- uses : actions/checkout@v2
- uses : actions/setup-node@v1
- run : npm run test
- run : npm run build
I want to run test and then build and only If there wasn't an error , push to the github repo .
How can I push to github repo only If test-code action passes ?
Solution
GitHub only knows about the code that was pushed to the repository. It's not able to verify anything that's available only on your local copy.
The action is invoked only on the code that is available in the GitHub repository – the code that was pushed there.
In other words doing exactly what you want is not possible.
You could do some validation prior to the push is accepted using hooks (like pre-receive
hook), but that is not that robust as actions.
I'd say that the thing that you're looking for is the workflow which would assume that merge requests/pull request are accepted only when GitHub action executed on the branch finishes successfully.
Answered By - Marcin Pietraszek Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.