Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

86 lines
2.8 KiB

name: Review app pipeline
on:
issue_comment:
types: [created]
defaults:
run:
shell: bash
jobs:
setup:
name: Resolve PR details
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/deploy-review')
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
pr_number: ${{ steps.resolve.outputs.pr_number }}
ref: ${{ steps.resolve.outputs.ref }}
steps:
- name: Resolve PR number and ref
id: resolve
uses: actions/github-script@v7
with:
script: |
const prNumber = context.issue.number;
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
core.setOutput('pr_number', prNumber.toString());
core.setOutput('ref', pr.head.ref);
infra:
name: Deploy review app infrastructure
needs: [setup]
uses: communitiesuk/submit-social-housing-lettings-and-sales-data-infrastructure/.github/workflows/create_review_app_infra.yml@main
with:
key: ${{ needs.setup.outputs.pr_number }}
app_repo_role: arn:aws:iam::815624722760:role/core-application-repo
permissions:
id-token: write
code:
name: Deploy review app code
needs: [setup, infra]
uses: ./.github/workflows/aws_deploy.yml
with:
aws_account_id: 837698168072
aws_role_prefix: core-dev
aws_task_prefix: core-review-${{ needs.setup.outputs.pr_number }}
concurrency_tag: ${{ needs.setup.outputs.pr_number }}
environment: review
permissions:
id-token: write
comment:
name: Add link to PR
needs: [setup, code]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Comment on PR with URL
uses: actions/github-script@v7
with:
script: |
const prNumber = ${{ needs.setup.outputs.pr_number }};
const body = `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,
});
const duplicate = comments.find(c => c.body.startsWith('Created review app at'));
if (!duplicate) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: body,
});
}