diff --git a/.github/workflows/manual_review_code_pipeline.yml b/.github/workflows/manual_review_code_pipeline.yml index 2ea0719ca..0e4ad747b 100644 --- a/.github/workflows/manual_review_code_pipeline.yml +++ b/.github/workflows/manual_review_code_pipeline.yml @@ -1,4 +1,4 @@ -name: Manual review app code pipeline +name: "Review App: Manual Code Redeploy" concurrency: group: review-${{ inputs.review_app_key }} 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_pipeline.yml index b31f81e23..c106b7a3c 100644 --- a/.github/workflows/review_pipeline.yml +++ b/.github/workflows/review_pipeline.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/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