From d87aba906b5a665ca6c664dfaf357df81e9f5d9b Mon Sep 17 00:00:00 2001 From: Nat Dean-Lewis <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:11:38 +0000 Subject: [PATCH] CLDC-4236: Deploy review apps manually using PR labels (#3238) * CLDC-4263: implement minimal label-based approach * CLDC-4263: add descriptive comment * CLDC-4263: separate comment workflow * CLDC-4263: add label check to code workflow * CLDC-4263: always hint initially * CLDC-4263: copy change test * Revert "CLDC-4263: copy change test" This reverts commit 09df8ab28f4cd86ca22c32a7abd8450cc379535c. * CLDC-4263: rename review app workflows for clarity * CLDC-4263: remove broken workflow_dispatches * CLDC-4263: rename label * CLDC-4236: renaming and commenting --- .github/workflows/production_pipeline.yml | 1 - .github/workflows/review_app_hint.yml | 23 ++++++++++++++ ...{review_pipeline.yml => review_deploy.yml} | 30 ++++++++++++++----- ...eline.yml => review_deploy_image_only.yml} | 3 +- .../workflows/review_teardown_pipeline.yml | 3 +- 5 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/review_app_hint.yml rename .github/workflows/{review_pipeline.yml => review_deploy.yml} (50%) rename .github/workflows/{manual_review_code_pipeline.yml => review_deploy_image_only.yml} (82%) diff --git a/.github/workflows/production_pipeline.yml b/.github/workflows/production_pipeline.yml index b4a188415..45a31167f 100644 --- a/.github/workflows/production_pipeline.yml +++ b/.github/workflows/production_pipeline.yml @@ -3,7 +3,6 @@ name: Production CI/CD Pipeline on: release: types: [released] - workflow_dispatch: defaults: run: diff --git a/.github/workflows/review_app_hint.yml b/.github/workflows/review_app_hint.yml new file mode 100644 index 000000000..ead73c856 --- /dev/null +++ b/.github/workflows/review_app_hint.yml @@ -0,0 +1,23 @@ +name: "Review App: PR Hint Comment" + +on: + pull_request: + types: [opened] + +jobs: + hint: + name: Add review app hint + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Comment on PR + uses: actions/github-script@v7 + with: + script: | + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: 'To deploy a review app for this PR, add the `review-app` label.', + }); diff --git a/.github/workflows/review_pipeline.yml b/.github/workflows/review_deploy.yml similarity index 50% rename from .github/workflows/review_pipeline.yml rename to .github/workflows/review_deploy.yml index b31f81e23..c106b7a3c 100644 --- a/.github/workflows/review_pipeline.yml +++ b/.github/workflows/review_deploy.yml @@ -1,4 +1,4 @@ -name: Review app pipeline +name: "Review App: Deploy" concurrency: group: review-${{ github.event.pull_request.number }} @@ -6,9 +6,9 @@ concurrency: on: pull_request: types: - - opened - synchronize - reopened + - labeled workflow_dispatch: defaults: @@ -18,6 +18,7 @@ defaults: jobs: infra: name: Deploy review app infrastructure + if: contains(github.event.pull_request.labels.*.name, 'review-app') uses: communitiesuk/submit-social-housing-lettings-and-sales-data-infrastructure/.github/workflows/create_review_app_infra.yml@main with: key: ${{ github.event.pull_request.number }} @@ -27,6 +28,7 @@ jobs: code: name: Deploy review app code + if: contains(github.event.pull_request.labels.*.name, 'review-app') needs: [infra] uses: ./.github/workflows/aws_deploy.yml with: @@ -40,6 +42,7 @@ jobs: comment: name: Add link to PR + if: contains(github.event.pull_request.labels.*.name, 'review-app') needs: [code] runs-on: ubuntu-latest permissions: @@ -48,10 +51,21 @@ jobs: steps: - name: Comment on PR with URL - uses: unsplash/comment-on-pr@v1.3.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/github-script@v7 with: - msg: "Created review app at https://review.submit-social-housing-data.communities.gov.uk/${{ github.event.pull_request.number }}. Note that the review app will be automatically deprovisioned after 30 days and will need the review app pipeline running again." - check_for_duplicate_msg: true - duplicate_msg_pattern: Created review app at* + script: | + const prNumber = context.issue.number; + const msg = `Created review app at https://review.submit-social-housing-data.communities.gov.uk/${prNumber}. Note that the review app will be automatically deprovisioned after 30 days and will need the review app pipeline running again.`; + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + }); + if (!comments.find(c => c.body.startsWith('Created review app at'))) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body: msg, + }); + } diff --git a/.github/workflows/manual_review_code_pipeline.yml b/.github/workflows/review_deploy_image_only.yml similarity index 82% rename from .github/workflows/manual_review_code_pipeline.yml rename to .github/workflows/review_deploy_image_only.yml index 2ea0719ca..366335f0f 100644 --- a/.github/workflows/manual_review_code_pipeline.yml +++ b/.github/workflows/review_deploy_image_only.yml @@ -1,4 +1,5 @@ -name: Manual review app code pipeline +# Pushes the Docker image to a review app, for use when the ECS image has expired. +name: "Review App: Deploy (ECS Image only)" concurrency: group: review-${{ inputs.review_app_key }} diff --git a/.github/workflows/review_teardown_pipeline.yml b/.github/workflows/review_teardown_pipeline.yml index 8925b3340..d2a49db4e 100644 --- a/.github/workflows/review_teardown_pipeline.yml +++ b/.github/workflows/review_teardown_pipeline.yml @@ -1,4 +1,4 @@ -name: Review app teardown pipeline +name: "Review App: Teardown" concurrency: group: review-${{ github.event.pull_request.number }} @@ -7,7 +7,6 @@ on: pull_request: types: - closed - workflow_dispatch: env: app_repo_role: arn:aws:iam::815624722760:role/core-application-repo