Browse Source
* Revert "CLDC-4236: misc pipeline updates (#3227)" This reverts commitpull/3194/headcee09718fd. * Revert "CLDC-4236: use correct sha ref for review apps" This reverts commit36918740f4. * Revert "CLDC-4236: use list-images in review app deployments" This reverts commit75ec4d1e75. * Revert "CLDC-4236: trigger review app deploys manually (#3216)" This reverts commit8a186d096c.
6 changed files with 37 additions and 255 deletions
@ -1,51 +1,29 @@ |
|||||||
name: Manual review app build and deploy |
name: Manual review app code pipeline |
||||||
|
|
||||||
concurrency: |
concurrency: |
||||||
group: deploy-review${{ inputs.pr_number }} |
group: review-${{ inputs.review_app_key }} |
||||||
|
|
||||||
on: |
on: |
||||||
workflow_dispatch: |
workflow_dispatch: |
||||||
inputs: |
inputs: |
||||||
pr_number: |
review_app_key: |
||||||
required: true |
required: true |
||||||
type: string |
type: string |
||||||
description: "The PR number of the review app to deploy code for. Note: this is NOT the ticket number" |
description: "The review app ID to deploy code for." |
||||||
|
|
||||||
permissions: {} |
|
||||||
|
|
||||||
defaults: |
defaults: |
||||||
run: |
run: |
||||||
shell: bash |
shell: bash |
||||||
|
|
||||||
jobs: |
jobs: |
||||||
get_pr_head_sha: |
|
||||||
name: Get PR HEAD SHA |
|
||||||
runs-on: ubuntu-latest |
|
||||||
outputs: |
|
||||||
pr_head_sha: ${{ steps.get_sha.outputs.pr_head_sha }} |
|
||||||
steps: |
|
||||||
- name: Get PR HEAD SHA |
|
||||||
id: get_sha |
|
||||||
uses: actions/github-script@v7 |
|
||||||
with: |
|
||||||
script: | |
|
||||||
const { data: pr } = await github.rest.pulls.get({ |
|
||||||
owner: context.repo.owner, |
|
||||||
repo: context.repo.repo, |
|
||||||
pull_number: parseInt('${{ inputs.pr_number }}'), |
|
||||||
}); |
|
||||||
core.setOutput('pr_head_sha', pr.head.sha); |
|
||||||
|
|
||||||
code: |
code: |
||||||
name: Deploy review app code |
name: Deploy review app code |
||||||
needs: [get_pr_head_sha] |
|
||||||
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-${{ inputs.pr_number }} |
aws_task_prefix: core-review-${{ inputs.review_app_key }} |
||||||
concurrency_tag: ${{ inputs.pr_number }} |
concurrency_tag: ${{ inputs.review_app_key }} |
||||||
environment: review |
environment: review |
||||||
ref: ${{ needs.get_pr_head_sha.outputs.pr_head_sha }} |
|
||||||
permissions: |
permissions: |
||||||
id-token: write |
id-token: write |
||||||
|
|||||||
@ -1,24 +0,0 @@ |
|||||||
name: Review app deploy prompt |
|
||||||
|
|
||||||
on: |
|
||||||
pull_request: |
|
||||||
types: [opened] |
|
||||||
|
|
||||||
jobs: |
|
||||||
prompt: |
|
||||||
name: Add review app deploy instructions |
|
||||||
runs-on: ubuntu-latest |
|
||||||
permissions: |
|
||||||
pull-requests: write |
|
||||||
|
|
||||||
steps: |
|
||||||
- name: Comment with deploy instructions |
|
||||||
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, comment `/deploy-review`.', |
|
||||||
}); |
|
||||||
@ -1,162 +1,57 @@ |
|||||||
name: Review app pipeline |
name: Review app pipeline |
||||||
|
|
||||||
|
concurrency: |
||||||
|
group: review-${{ github.event.pull_request.number }} |
||||||
|
|
||||||
on: |
on: |
||||||
issue_comment: |
|
||||||
types: [created] |
|
||||||
workflow_dispatch: |
|
||||||
inputs: |
|
||||||
pr_number: |
|
||||||
required: true |
|
||||||
type: string |
|
||||||
description: "The number of the PR for which to deploy a review app. Note: this is NOT the ticket number" |
|
||||||
pull_request: |
pull_request: |
||||||
types: [synchronize] |
types: |
||||||
|
- opened |
||||||
concurrency: |
- synchronize |
||||||
group: deploy-review${{ github.event.pull_request.number || inputs.pr_number || github.event.issue.number }} |
- reopened |
||||||
|
workflow_dispatch: |
||||||
|
|
||||||
permissions: {} |
defaults: |
||||||
|
run: |
||||||
|
shell: bash |
||||||
|
|
||||||
jobs: |
jobs: |
||||||
get_pr_details: |
|
||||||
name: Get PR details |
|
||||||
if: github.event_name == 'workflow_dispatch' || (github.event.issue.pull_request && startsWith(github.event.comment.body, '/deploy-review')) || github.event_name == 'pull_request' |
|
||||||
runs-on: ubuntu-latest |
|
||||||
outputs: |
|
||||||
pr_number: ${{ steps.get_pr_details.outputs.pr_number }} |
|
||||||
pr_head_sha: ${{ steps.get_pr_details.outputs.pr_head_sha }} |
|
||||||
steps: |
|
||||||
- name: Get PR number and HEAD SHA |
|
||||||
id: get_pr_details |
|
||||||
uses: actions/github-script@v7 |
|
||||||
with: |
|
||||||
script: | |
|
||||||
let prNumber; |
|
||||||
if (context.eventName === 'workflow_dispatch') { |
|
||||||
prNumber = '${{ inputs.pr_number }}'; |
|
||||||
} else if (context.eventName === 'pull_request') { |
|
||||||
prNumber = context.payload.pull_request.number.toString(); |
|
||||||
} else { |
|
||||||
prNumber = context.issue.number.toString(); |
|
||||||
} |
|
||||||
core.setOutput('pr_number', prNumber); |
|
||||||
const { data: pr } = await github.rest.pulls.get({ |
|
||||||
owner: context.repo.owner, |
|
||||||
repo: context.repo.repo, |
|
||||||
pull_number: parseInt(prNumber), |
|
||||||
}); |
|
||||||
core.setOutput('pr_head_sha', pr.head.sha); |
|
||||||
|
|
||||||
check_deployment_started: |
|
||||||
name: Check if deployment has been started |
|
||||||
if: github.event_name == 'pull_request' |
|
||||||
needs: [get_pr_details] |
|
||||||
runs-on: ubuntu-latest |
|
||||||
permissions: |
|
||||||
pull-requests: read |
|
||||||
outputs: |
|
||||||
started: ${{ steps.check.outputs.started }} |
|
||||||
steps: |
|
||||||
- name: Check for previous deployment workflow runs |
|
||||||
id: check |
|
||||||
uses: actions/github-script@v7 |
|
||||||
with: |
|
||||||
script: | |
|
||||||
const prNumber = '${{ needs.get_pr_details.outputs.pr_number }}'; |
|
||||||
const { data: comments } = await github.rest.issues.listComments({ |
|
||||||
owner: context.repo.owner, |
|
||||||
repo: context.repo.repo, |
|
||||||
issue_number: parseInt(prNumber), |
|
||||||
}); |
|
||||||
const deployComment = comments.find(c => c.body === 'Starting review app deployment...'); |
|
||||||
core.setOutput('started', deployComment ? 'true' : 'false'); |
|
||||||
|
|
||||||
deployment_started_comment: |
|
||||||
name: Comment deployment started |
|
||||||
if: github.event_name != 'pull_request' |
|
||||||
needs: [get_pr_details] |
|
||||||
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: ${{ needs.get_pr_details.outputs.pr_number }}, |
|
||||||
body: 'Starting review app deployment...', |
|
||||||
}); |
|
||||||
|
|
||||||
infra: |
infra: |
||||||
name: Deploy review app infrastructure |
name: Deploy review app infrastructure |
||||||
if: github.event_name != 'pull_request' |
|
||||||
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.get_pr_details.outputs.pr_number }} |
key: ${{ github.event.pull_request.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 |
||||||
if: github.event_name != 'pull_request' |
needs: [infra] |
||||||
needs: [get_pr_details, infra] |
|
||||||
uses: ./.github/workflows/aws_deploy.yml |
|
||||||
with: |
|
||||||
aws_account_id: 837698168072 |
|
||||||
aws_role_prefix: core-dev |
|
||||||
aws_task_prefix: core-review-${{ needs.get_pr_details.outputs.pr_number }} |
|
||||||
concurrency_tag: ${{ needs.get_pr_details.outputs.pr_number }} |
|
||||||
environment: review |
|
||||||
ref: ${{ needs.get_pr_details.outputs.pr_head_sha }} |
|
||||||
permissions: |
|
||||||
id-token: write |
|
||||||
|
|
||||||
auto_update_code: |
|
||||||
name: Auto-update review app code |
|
||||||
if: github.event_name == 'pull_request' && needs.check_deployment_started.outputs.started == 'true' |
|
||||||
needs: [get_pr_details, check_deployment_started] |
|
||||||
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.get_pr_details.outputs.pr_number }} |
aws_task_prefix: core-review-${{ github.event.pull_request.number }} |
||||||
concurrency_tag: ${{ needs.get_pr_details.outputs.pr_number }} |
concurrency_tag: ${{ github.event.pull_request.number }} |
||||||
environment: review |
environment: review |
||||||
ref: ${{ needs.get_pr_details.outputs.pr_head_sha }} |
|
||||||
permissions: |
permissions: |
||||||
id-token: write |
id-token: write |
||||||
|
|
||||||
comment: |
comment: |
||||||
name: Add link to PR |
name: Add link to PR |
||||||
if: github.event_name != 'pull_request' |
needs: [code] |
||||||
needs: [get_pr_details, code] |
|
||||||
runs-on: ubuntu-latest |
runs-on: ubuntu-latest |
||||||
permissions: |
permissions: |
||||||
|
issues: write |
||||||
pull-requests: write |
pull-requests: write |
||||||
|
|
||||||
steps: |
steps: |
||||||
- name: Comment on PR with URL |
- name: Comment on PR with URL |
||||||
uses: actions/github-script@v7 |
uses: unsplash/comment-on-pr@v1.3.0 |
||||||
|
env: |
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||||
with: |
with: |
||||||
script: | |
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." |
||||||
const prNumber = ${{ needs.get_pr_details.outputs.pr_number }}; |
check_for_duplicate_msg: true |
||||||
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.`; |
duplicate_msg_pattern: Created review app at* |
||||||
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, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|||||||
Loading…
Reference in new issue