Browse Source

CLDC-4136: change check if review app exists to check if review app deployment started to avoid not deploying changes made during first deployment

pull/3227/head
Nat Dean-Lewis 1 week ago
parent
commit
f0e3dff785
  1. 55
      .github/workflows/review_pipeline.yml

55
.github/workflows/review_pipeline.yml

@ -47,37 +47,40 @@ jobs:
}); });
core.setOutput('pr_head_sha', pr.head.sha); core.setOutput('pr_head_sha', pr.head.sha);
check_review_app_exists: check_deployment_started:
name: Check if review app exists name: Check if deployment has been started
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
needs: [get_pr_details] needs: [get_pr_details]
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
id-token: write actions: read
outputs: outputs:
exists: ${{ steps.check.outputs.exists }} started: ${{ steps.check.outputs.started }}
steps: steps:
- name: Configure AWS credentials - name: Check for previous deployment workflow runs
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
id: check id: check
run: | uses: actions/github-script@v7
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 with:
echo "exists=true" >> $GITHUB_OUTPUT script: |
else const prNumber = '${{ needs.get_pr_details.outputs.pr_number }}';
echo "exists=false" >> $GITHUB_OUTPUT const { data: runs } = await github.rest.actions.listWorkflowRuns({
fi 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: deployment_started_comment:
name: Comment deployment started name: Comment deployment started
@ -126,8 +129,8 @@ jobs:
auto_update_code: auto_update_code:
name: Auto-update review app code name: Auto-update review app code
if: github.event_name == 'pull_request' && needs.check_review_app_exists.outputs.exists == 'true' if: github.event_name == 'pull_request' && needs.check_deployment_started.outputs.started == 'true'
needs: [get_pr_details, check_review_app_exists] 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

Loading…
Cancel
Save