Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Action avoid approval on same environment rule within same workflow

Reusing same environment rule within same workflow

Running our workflow in Github, we split our tasks up into 2 jobs; Building docker image & attach tags and deploying to AWS using CodeDeploy. The reason for splitting the tasks up is to avoid creating new tags whenever our deployment fails.

However... using environment protection rules creates a roadblock as every job needs to be approved(even though we already ran the same environment previously)

The deployment job is a conditional job, meaning it depends on the success of the Build job.

Is there any way to get around this?

Github workflow

like image 635
hanayama Avatar asked Mar 18 '26 05:03

hanayama


1 Answers

I'm not sure I have the full context here but based on the above screenshot here would be my recommendation.

  1. Update the workflow to build and push the container image once. Ideally, you want to build once and deploy many anyway to ensure your container is the same across each environment.
  2. Update the workflow to do a sequential deployment -- dev -> pre-prod -> prod by adding a needs block for each environment.
  3. Add a unique GitHub environment for each deployment job which will have their own protection rules. Or maybe you don't care about approving deployments to the dev environment -- so just don't add an environment rule for that deployment environment.

Hopefully this helps provide some guidance.

like image 96
John Veldboom Avatar answered Mar 19 '26 22:03

John Veldboom