@@ -32,10 +32,53 @@ permissions:
3232 contents : read
3333
3434jobs :
35+ configure_deployments :
36+ name : Configure deployments
37+ runs-on : ubuntu-latest
38+ outputs :
39+ environments : ${{ steps.define_environments.outputs.environments }}
40+ commit_hash : ${{ steps.define_commit_hash.outputs.commit_hash }}
41+ steps :
42+ - id : define_environments
43+ name : Define environments configurations
44+ run : |
45+ # Select all environments up to and including the one selected for the
46+ # release
47+ environments=""
48+ for env in "dev" "qa" "staging" "prod"; do
49+ environments+="\"$env\", "
50+ if [[ $env == "${{ inputs.publish_environment }}" ]]; then
51+ break
52+ fi
53+ done
54+ environments=${environments/%, /} # remove trailing comma
55+ echo "Publishing compass-web to $environments"
56+ echo "environments=[$environments]" >> "$GITHUB_OUTPUT"
57+ - id : define_commit_hash
58+ name : Resolve release hash
59+ env :
60+ COMPASS_WEB_RELEASE_COMMIT : ' ${{ inputs.dangerously_override_commit_hash }}'
61+ run : |
62+ # Use latest dev deploy as a default one for the release: this matches
63+ # our continuous deployment strategy
64+ commit_hash=${COMPASS_WEB_RELEASE_COMMIT:-"$(npm run --silent latest-release -w packages/compass-web dev)"}
65+ echo "commit_hash=\"$commit_hash\"" >> "$GITHUB_OUTPUT"
66+
3567 publish :
36- name : Upload compass-web entrypoint file to assets bucket
68+ name : Upload compass-web entrypoint file to assets bucket in ${{ matrix.environment }}
3769 runs-on : ubuntu-latest
70+ needs : configure_deployments
71+ strategy :
72+ # By using matrix with max parallel we run the combinations in sequence
73+ # one after another. The fail fast option guarantees that deploy doesn't
74+ # proceed when a previous one failed
75+ max-parallel : 1
76+ fail-fast : true
77+ matrix :
78+ environment : ${{ fromJSON(needs.configure_deployments.outputs.environments) }}
3879 environment : compass-web
80+ outputs :
81+ environments : ${{ steps.check_if_deployed.outputs.already_deployed }}
3982 steps :
4083 - name : Checkout
4184 uses : actions/checkout@v4
@@ -64,28 +107,42 @@ jobs:
64107 run : |
65108 npm ci
66109
110+ - id : check_if_deployed
111+ name : Check current release version for ${{ matrix.environment }} env
112+ env :
113+ COMPASS_WEB_RELEASE_COMMIT : ${{ inputs.dangerously_override_commit_hash }}
114+ run : |
115+ current_release_commit_hash="$(npm run --silent latest-release -w packages/compass-web ${{ matrix.environment }})"
116+ if [[ $current_release_commit_hash == $COMPASS_WEB_RELEASE_COMMIT ]]; then
117+ echo "Release $COMPASS_WEB_RELEASE_COMMIT already published on ${{ matrix.environment }}"
118+ echo "already_deployed=true" >> "$GITHUB_OUTPUT"
119+ fi
120+
67121 - name : Test compass-web with Atlas Cloud
68- if : ${{ !inputs.dangerously_skip_e2e_tests }}
122+ # TODO(CLOUDP-388180): can't run automated tests in staging, prod environments at the moment
123+ if : ${{ !steps.check_if_deployed.outputs.already_deployed && !inputs.dangerously_skip_e2e_tests && contains(fromJSON('["dev", "qa"]'), matrix.environment) }}
69124 env :
70125 EVG_USER : ${{ secrets.EVERGREEN_SERVICE_USER_USERNAME }}
71126 EVG_API_KEY : ${{ secrets.EVERGREEN_SERVICE_USER_API_KEY }}
72- COMPASS_E2E_ATLAS_CLOUD_ENVIRONMENT : ${{ inputs.publish_environment }}
73- COMPASS_WEB_E2E_TEST_EVERGREEN_PATCH_DESCRIPTION : ' Test compass-web against Atlas ${{ inputs.publish_environment }} env before release (GHA: https://github.com/mongodb-js/compass/actions/runs/${{ github.run_id }})'
74- COMPASS_WEB_RELEASE_COMMIT : ${{ inputs.dangerously_override_commit_hash }}
127+ COMPASS_E2E_ATLAS_CLOUD_ENVIRONMENT : ${{ matrix.environment }}
128+ COMPASS_WEB_E2E_TEST_EVERGREEN_PATCH_DESCRIPTION : ' Test compass-web against Atlas ${{ matrix.environment }} env before release (GHA: https://github.com/mongodb-js/compass/actions/runs/${{ github.run_id }})'
129+ COMPASS_WEB_RELEASE_COMMIT : ${{ steps.define_commit_hash.outputs.commit_hash }}
75130 run : |
76131 npm run --workspace @mongodb-js/compass-web test-e2e-atlas
77132
78133 - name : Configure AWS Credentials
134+ if : ${{ !steps.check_if_deployed.outputs.already_deployed }}
79135 uses : aws-actions/configure-aws-credentials@56d6a583f00f6bad6d19d91d53a7bc3b8143d0e9 # v5.1.1
80136 with :
81137 role-to-assume : arn:aws:iam::119629040606:role/s3-access.cdn-origin-compass
82138 aws-region : us-east-1
83139
84140 - name : Upload updated entrypoint
141+ if : ${{ !steps.check_if_deployed.outputs.already_deployed }}
85142 env :
86143 COMPASS_WEB_PUBLISH_DRY_RUN : ${{ inputs.dry_run }}
87- COMPASS_WEB_PUBLISH_ENVIRONMENT : ${{ inputs.publish_environment }}
88- COMPASS_WEB_RELEASE_COMMIT : ${{ inputs.dangerously_override_commit_hash }}
144+ COMPASS_WEB_PUBLISH_ENVIRONMENT : ${{ matrix.environment }}
145+ COMPASS_WEB_RELEASE_COMMIT : ${{ steps.define_commit_hash.outputs.commit_hash }}
89146 # Set by "Configure AWS Credentials" step
90147 DOWNLOAD_CENTER_NEW_AWS_ACCESS_KEY_ID : ' ${{ env.AWS_ACCESS_KEY_ID }}'
91148 DOWNLOAD_CENTER_NEW_AWS_SECRET_ACCESS_KEY : ' ${{ env.AWS_SECRET_ACCESS_KEY }}'
0 commit comments