PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 27, 2022

[FIXED] How to decline git push when ci workflow file has an error?

 September 27, 2022     continuous-deployment, continuous-integration, git, github     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing