Search code examples
amazon-web-servicescontinuous-integrationgithub-actionsaws-cdk

Github Actions to only apply the review position for specific jobs in a workflow


I am new to GitHub actions. I use it to deploy to an AWS account, a lambda application committed to a GitHub repository. Currently, I am using this workflow below so that only a pull request that is merged and closed will trigger the workflow. This is a dotnet application which requires a build step.

name: Deploying Lambda

on:
  pull_request:
    types: [closed]
    branches:
      - 'dev'

jobs:

  build-latest:
    runs-on: ubuntu-latest
    environment: DEV

    steps:
      # ... existing steps

  unit-tests-and-cdknag-execution:
    needs: get-latest-and-build
    runs-on: ubuntu-latest
    environment: DEV

    steps:
      # ... existing steps

  deploy-build:
    needs: unit-tests-execution
    runs-on: ubuntu-latest
    environment: DEV


    steps:
      # ... existing steps 

I don't want the review happening at every job. It should only happen for the deploy-build job. The GitHub console doesn't allow me to specify which job the approval should be asked for. When I set up the environment for requiring approval, it does it automatically for all jobs in the workflow. Is there a way around this?


Solution

  • Remove

    environment; DEV
    

    from all other jobs. It should only be set on the deploy-build job.