github-actions

Review App Reconcile

Review App Reconcile

*only if dry_run is set to false

Inputs

Example


name: Reconcile review apps on AKS

on:
  workflow_dispatch:
    inputs:
      dry_run:
        description: "Only display stale review apps; do not delete"
        required: true
        default: true
        type: boolean
  # schedule:
  #   - cron: "0 */6 * * *"

permissions:
  id-token: write
  pull-requests: write
  contents: read

env:
  GLOBAL_CONFIG_PATH: config/global_config
  TF_VARS_PATH: config/terraform/application/config
  TERRAFORM_BASE: config/terraform/application
  SERVICE_NAME: cpd-ec2
  RESOURCE_GROUP_NAME: s189t01-cpdec2-rv-rg
  STORAGE_ACCOUNT_NAME: s189t01cpdec2rvtfsa
  CONTAINER_NAME: terraform-state

jobs:
  display-review-apps-to-remove:
    name: Reconcile review apps
    runs-on: ubuntu-latest

    environment: review

    outputs:
      stale_prs: $

    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          token: $

      - name: Reconcile review apps
        id: reconcile
        uses: DFE-Digital/github-actions/review-app-reconcile@2689-check-delete-review-app
        with:
          azure-subscription-id: $
          azure-client-id: $
          azure-tenant-id: $
          resource-group-name: $
          storage-account-name: $
          terraform-base: $
          service-name: $
          github-token: $
          github-repo: $
          tf-vars-path: $
          global-config-path: $

  delete-review-apps-after-reconcile:
     name: Delete review app $ after reconcile
     needs: display-review-apps-to-remove
     runs-on: ubuntu-latest
     environment: review

     if: >
       github.event.inputs.dry_run == 'false' &&
       needs.display-review-apps-to-remove.outputs.stale_prs != '[]'

     strategy:
       fail-fast: false
       matrix:
         pr_number: $

     concurrency: deploy_review_$

     steps:
       - name: Checkout
         uses: actions/checkout@v6
         with:
           token: $

       - name: Delete stale review app
         uses: DFE-Digital/github-actions/delete-review-app@master
         env:
           PULL_REQUEST_NUMBER: $
         with:
           azure-subscription-id: $
           azure-client-id: $
           azure-tenant-id: $
           gcp-wip: projects/808138694727/locations/global/workloadIdentityPools/register-early-career-teachers-p/provider-p/register-early-career-teachers-p
           gcp-project-id: ecf-bq
           terraform-base: $
           gcp-wip: $
           gcp-project-id: $
           pr-number: $
           resource-group-name: $
           storage-account-name: $
           container-name: $
           tf-state-file: review-$_kubernetes.tfstate