Browse Source

CLDC-4236: refactor

pull/3217/head
Nat Dean-Lewis 2 months ago
parent
commit
cceb276962
  1. 40
      .github/workflows/review_pipeline.yml

40
.github/workflows/review_pipeline.yml

@ -4,61 +4,47 @@ on:
issue_comment: issue_comment:
types: [created] types: [created]
defaults:
run:
shell: bash
jobs: jobs:
setup: get_pr_details:
name: Resolve PR details name: Get PR details
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/deploy-review') if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/deploy-review')
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs: outputs:
pr_number: ${{ steps.resolve.outputs.pr_number }} pr_number: ${{ steps.get_pr_details.outputs.pr_number }}
ref: ${{ steps.resolve.outputs.ref }}
steps: steps:
- name: Resolve PR number and ref - name: Get PR number
id: resolve id: get_pr_details
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
const prNumber = context.issue.number; core.setOutput('pr_number', context.issue.number.toString());
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: infra:
name: Deploy review app infrastructure name: Deploy review app infrastructure
needs: [setup] needs: [get_pr_details]
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: ${{ needs.setup.outputs.pr_number }} key: ${{ needs.get_pr_details.outputs.pr_number }}
app_repo_role: arn:aws:iam::815624722760:role/core-application-repo app_repo_role: arn:aws:iam::815624722760:role/core-application-repo
permissions: permissions:
id-token: write id-token: write
code: code:
name: Deploy review app code name: Deploy review app code
needs: [setup, infra] needs: [get_pr_details, infra]
uses: ./.github/workflows/aws_deploy.yml uses: ./.github/workflows/aws_deploy.yml
with: with:
aws_account_id: 837698168072 aws_account_id: 837698168072
aws_role_prefix: core-dev aws_role_prefix: core-dev
aws_task_prefix: core-review-${{ needs.setup.outputs.pr_number }} aws_task_prefix: core-review-${{ needs.get_pr_details.outputs.pr_number }}
concurrency_tag: ${{ needs.setup.outputs.pr_number }} concurrency_tag: ${{ needs.get_pr_details.outputs.pr_number }}
environment: review environment: review
permissions: permissions:
id-token: write id-token: write
comment: comment:
name: Add link to PR name: Add link to PR
needs: [setup, code] needs: [get_pr_details, code]
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
pull-requests: write pull-requests: write
@ -68,7 +54,7 @@ jobs:
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
const prNumber = ${{ needs.setup.outputs.pr_number }}; const prNumber = ${{ needs.get_pr_details.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 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({ const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner, owner: context.repo.owner,

Loading…
Cancel
Save