|
|
|
|
@ -47,37 +47,40 @@ jobs:
|
|
|
|
|
}); |
|
|
|
|
core.setOutput('pr_head_sha', pr.head.sha); |
|
|
|
|
|
|
|
|
|
check_review_app_exists: |
|
|
|
|
name: Check if review app exists |
|
|
|
|
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: |
|
|
|
|
id-token: write |
|
|
|
|
actions: read |
|
|
|
|
outputs: |
|
|
|
|
exists: ${{ steps.check.outputs.exists }} |
|
|
|
|
started: ${{ steps.check.outputs.started }} |
|
|
|
|
steps: |
|
|
|
|
- name: Configure AWS credentials |
|
|
|
|
uses: aws-actions/configure-aws-credentials@v4 |
|
|
|
|
with: |
|
|
|
|
aws-region: eu-west-2 |
|
|
|
|
role-to-assume: arn:aws:iam::815624722760:role/core-application-repo |
|
|
|
|
|
|
|
|
|
- name: Configure AWS credentials for review environment |
|
|
|
|
uses: aws-actions/configure-aws-credentials@v4 |
|
|
|
|
with: |
|
|
|
|
aws-region: eu-west-2 |
|
|
|
|
role-to-assume: arn:aws:iam::837698168072:role/core-dev-deployment |
|
|
|
|
role-chaining: true |
|
|
|
|
|
|
|
|
|
- name: Check if ECS service exists |
|
|
|
|
- name: Check for previous deployment workflow runs |
|
|
|
|
id: check |
|
|
|
|
run: | |
|
|
|
|
if aws ecs describe-services --cluster core-review-${{ needs.get_pr_details.outputs.pr_number }}-app --services core-review-${{ needs.get_pr_details.outputs.pr_number }}-app --query "services[?status=='ACTIVE']" | grep -q 'serviceName'; then |
|
|
|
|
echo "exists=true" >> $GITHUB_OUTPUT |
|
|
|
|
else |
|
|
|
|
echo "exists=false" >> $GITHUB_OUTPUT |
|
|
|
|
fi |
|
|
|
|
uses: actions/github-script@v7 |
|
|
|
|
with: |
|
|
|
|
script: | |
|
|
|
|
const prNumber = '${{ needs.get_pr_details.outputs.pr_number }}'; |
|
|
|
|
const { data: runs } = await github.rest.actions.listWorkflowRuns({ |
|
|
|
|
owner: context.repo.owner, |
|
|
|
|
repo: context.repo.repo, |
|
|
|
|
workflow_id: 'review_pipeline.yml', |
|
|
|
|
event: 'issue_comment', |
|
|
|
|
}); |
|
|
|
|
const { data: dispatchRuns } = await github.rest.actions.listWorkflowRuns({ |
|
|
|
|
owner: context.repo.owner, |
|
|
|
|
repo: context.repo.repo, |
|
|
|
|
workflow_id: 'review_pipeline.yml', |
|
|
|
|
event: 'workflow_dispatch', |
|
|
|
|
}); |
|
|
|
|
const allRuns = [...runs.workflow_runs, ...dispatchRuns.workflow_runs]; |
|
|
|
|
const prRun = allRuns.find(run => |
|
|
|
|
run.display_title.includes(`#${prNumber}`) || |
|
|
|
|
run.head_branch === context.payload.pull_request.head.ref |
|
|
|
|
); |
|
|
|
|
core.setOutput('started', prRun ? 'true' : 'false'); |
|
|
|
|
|
|
|
|
|
deployment_started_comment: |
|
|
|
|
name: Comment deployment started |
|
|
|
|
@ -126,8 +129,8 @@ jobs:
|
|
|
|
|
|
|
|
|
|
auto_update_code: |
|
|
|
|
name: Auto-update review app code |
|
|
|
|
if: github.event_name == 'pull_request' && needs.check_review_app_exists.outputs.exists == 'true' |
|
|
|
|
needs: [get_pr_details, check_review_app_exists] |
|
|
|
|
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 |
|
|
|
|
with: |
|
|
|
|
aws_account_id: 837698168072 |
|
|
|
|
|