@ -1,4 +1,4 @@
name : Review app pipeline
name : "Review App: Deploy"
concurrency:
concurrency:
group : review-${{ github.event.pull_request.number }}
group : review-${{ github.event.pull_request.number }}
@ -6,9 +6,9 @@ concurrency:
on :
on :
pull_request:
pull_request:
types:
types:
- opened
- synchronize
- synchronize
- reopened
- reopened
- labeled
workflow_dispatch:
workflow_dispatch:
defaults:
defaults:
@ -18,6 +18,7 @@ defaults:
jobs:
jobs:
infra:
infra:
name : Deploy review app infrastructure
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
uses : communitiesuk/submit-social-housing-lettings-and-sales-data-infrastructure/.github/workflows/create_review_app_infra.yml@main
with:
with:
key : ${{ github.event.pull_request.number }}
key : ${{ github.event.pull_request.number }}
@ -27,6 +28,7 @@ jobs:
code:
code:
name : Deploy review app code
name : Deploy review app code
if : contains(github.event.pull_request.labels.*.name, 'review-app')
needs : [ infra]
needs : [ infra]
uses : ./.github/workflows/aws_deploy.yml
uses : ./.github/workflows/aws_deploy.yml
with:
with:
@ -40,6 +42,7 @@ jobs:
comment:
comment:
name : Add link to PR
name : Add link to PR
if : contains(github.event.pull_request.labels.*.name, 'review-app')
needs : [ code]
needs : [ code]
runs-on : ubuntu-latest
runs-on : ubuntu-latest
permissions:
permissions:
@ -48,10 +51,21 @@ jobs:
steps:
steps:
- name : Comment on PR with URL
- name : Comment on PR with URL
uses : unsplash/comment-on-pr@v1.3.0
uses : actions/github-script@v7
env:
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
with:
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."
script : |
check_for_duplicate_msg : true
const prNumber = context.issue.number;
duplicate_msg_pattern : Created review app at*
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,
});
}