Skip to content

Commit

Permalink
chore: update deploy script to copy dependencies first
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs committed Dec 6, 2024
1 parent d0bde6d commit bf88dc5
Showing 1 changed file with 44 additions and 80 deletions.
124 changes: 44 additions & 80 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ jobs:
echo "Checkout SHA: $sha"
echo "SHA=$sha" >> $GITHUB_OUTPUT
- name: Checkout
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: ${{ steps.getSHA.outputs.SHA }}

- name: Get new version number
- name: Get new versions
run: |
current_version_v1=$(jq -r .version packages/analytics-v1.1/package.json)
current_version=$(jq -r .version packages/analytics-js/package.json)
Expand All @@ -96,7 +96,7 @@ jobs:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install dependencies
- name: Setup workspace
env:
HUSKY: 0
REMOTE_MODULES_BASE_PATH: 'https://cdn.rudderlabs.com/${{ inputs.s3_dir_path }}/modern/plugins'
Expand All @@ -105,27 +105,27 @@ jobs:
run: |
npm run setup:ci
- name: Build release artifacts
- name: Build artifacts
env:
BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }}
BUGSNAG_RELEASE_STAGE: ${{ inputs.bugsnag_release_stage }}
run: |
npm run build:browser
npm run build:browser:modern
- name: Sync Adobe Analytics assets to S3
- name: Copy assets to S3
if: ${{ inputs.environment == 'production' }}
run: |
aws s3 cp assets/integrations/AdobeAnalytics/ s3://${{ secrets.AWS_S3_BUCKET_NAME }}/adobe-analytics-js --recursive --cache-control ${{ env.CACHE_CONTROL }}
- name: Create Cloudfront invalidation
- name: Invalidate CloudFront cache for assets
if: ${{ inputs.environment == 'production' }}
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/adobe-analytics-js*"
- name: Sync files to S3
- name: Copy SDK dependencies to S3
if: false
run: |
core_sdk_path_prefix="packages/analytics-js/dist/cdn"
integration_sdks_path_prefix="packages/analytics-js-integrations/dist/cdn"
plugins_path_prefix="packages/analytics-js-plugins/dist/cdn"
s3_relative_path_prefix="${{ inputs.s3_dir_path }}"
Expand Down Expand Up @@ -153,12 +153,10 @@ jobs:
mv "$tmp_file" "$plugins_path_prefix/modern/plugins/$plugins_zip_file"
# Upload all the files to S3
aws s3 cp $core_sdk_path_prefix/legacy/iife/ $s3_path_prefix/legacy/ $copy_args
# aws s3 cp $integration_sdks_path_prefix/legacy/js-integrations/ $s3_path_prefix/legacy/js-integrations/ $copy_args
aws s3 cp $integration_sdks_path_prefix/legacy/js-integrations/ $s3_path_prefix/legacy/js-integrations/ $copy_args
# aws s3 cp $core_sdk_path_prefix/modern/iife/ $s3_path_prefix/modern/ $copy_args
# aws s3 cp $plugins_path_prefix/modern/plugins/ $s3_path_prefix/modern/plugins/ $copy_args
# aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/ $s3_path_prefix/modern/js-integrations/ $copy_args
aws s3 cp $plugins_path_prefix/modern/plugins/ $s3_path_prefix/modern/plugins/ $copy_args
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/ $s3_path_prefix/modern/js-integrations/ $copy_args
# Generate the HTML file to list all the integrations
./scripts/list-sdk-components.sh ${{ secrets.AWS_S3_BUCKET_NAME }} $s3_relative_path_prefix/legacy/js-integrations $integration_sdks_html_file $integration_sdks_path_prefix/legacy/js-integrations "Device Mode Integrations (Legacy)" $integration_sdks_zip_file
Expand All @@ -173,14 +171,24 @@ jobs:
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/$integration_sdks_html_file $s3_path_prefix/modern/js-integrations/$integration_sdks_html_file $copy_args
aws s3 cp $plugins_path_prefix/modern/plugins/$plugins_html_file $s3_path_prefix/modern/plugins/$plugins_html_file $copy_args
- name: Create Cloudfront invalidation
- name: Copy core SDK artifacts to S3
run: |
core_sdk_path_prefix="packages/analytics-js/dist/cdn"
s3_relative_path_prefix="${{ inputs.s3_dir_path }}"
s3_path_prefix="s3://${{ secrets.AWS_S3_BUCKET_NAME }}/$s3_relative_path_prefix"
copy_args="--recursive --cache-control ${{ env.CACHE_CONTROL }}"
# Upload all the files to S3
aws s3 cp $core_sdk_path_prefix/legacy/iife/ $s3_path_prefix/legacy/ $copy_args
aws s3 cp $core_sdk_path_prefix/modern/iife/ $s3_path_prefix/modern/ $copy_args
- name: Invalidate CloudFront cache for all the SDK artifacts
run: |
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/${{ inputs.s3_dir_path }}/*"
- name: Sync files to S3 versioned directory
- name: Copy SDK dependencies to S3 (versioned directory)
if: ${{ inputs.environment == 'production' }}
run: |
core_sdk_path_prefix="packages/analytics-js/dist/cdn"
integration_sdks_path_prefix="packages/analytics-js-integrations/dist/cdn"
plugins_path_prefix="packages/analytics-js-plugins/dist/cdn"
s3_relative_path_prefix="${{ env.CURRENT_VERSION_VALUE }}"
Expand All @@ -194,10 +202,8 @@ jobs:
plugins_html_file="list.html"
# Copy all the files to S3
aws s3 cp $core_sdk_path_prefix/legacy/iife/ $s3_path_prefix/legacy/ $copy_args
aws s3 cp $integration_sdks_path_prefix/legacy/js-integrations/ $s3_path_prefix/legacy/js-integrations/ $copy_args
aws s3 cp $core_sdk_path_prefix/modern/iife/ $s3_path_prefix/modern/ $copy_args
aws s3 cp $plugins_path_prefix/modern/plugins/ $s3_path_prefix/modern/plugins/ $copy_args
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/ $s3_path_prefix/modern/js-integrations/ $copy_args
Expand All @@ -214,53 +220,22 @@ jobs:
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/$integration_sdks_html_file $s3_path_prefix/modern/js-integrations/$integration_sdks_html_file $copy_args
aws s3 cp $plugins_path_prefix/modern/plugins/$plugins_html_file $s3_path_prefix/modern/plugins/$plugins_html_file $copy_args
- name: Create Cloudfront invalidation
if: ${{ inputs.environment == 'production' }}
run: |
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/${{ env.CURRENT_VERSION_VALUE }}/*"
# TODO: The '/latest' directory is unused. Might be removed in future.
- name: Sync files to S3 latest
- name: Copy core SDK artifacts to S3 (versioned directory)
if: ${{ inputs.environment == 'production' }}
run: |
core_sdk_path_prefix="packages/analytics-js/dist/cdn"
integration_sdks_path_prefix="packages/analytics-js-integrations/dist/cdn"
plugins_path_prefix="packages/analytics-js-plugins/dist/cdn"
s3_relative_path_prefix="latest"
s3_relative_path_prefix="${{ env.CURRENT_VERSION_VALUE }}"
s3_path_prefix="s3://${{ secrets.AWS_S3_BUCKET_NAME }}/$s3_relative_path_prefix"
copy_args="--recursive --cache-control ${{ env.CACHE_CONTROL }}"
integration_sdks_zip_file="all_integration_sdks.tar.gz"
plugins_zip_file="all_plugins.tar.gz"
integration_sdks_html_file="list.html"
plugins_html_file="list.html"
# Copy all the files to S3
aws s3 cp $core_sdk_path_prefix/legacy/iife/ $s3_path_prefix/legacy/ $copy_args
aws s3 cp $integration_sdks_path_prefix/legacy/js-integrations/ $s3_path_prefix/legacy/js-integrations/ $copy_args
aws s3 cp $core_sdk_path_prefix/modern/iife/ $s3_path_prefix/modern/ $copy_args
aws s3 cp $plugins_path_prefix/modern/plugins/ $s3_path_prefix/modern/plugins/ $copy_args
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/ $s3_path_prefix/modern/js-integrations/ $copy_args
# Generate the HTML file to list all the integrations
./scripts/list-sdk-components.sh ${{ secrets.AWS_S3_BUCKET_NAME }} $s3_relative_path_prefix/legacy/js-integrations $integration_sdks_html_file $integration_sdks_path_prefix/legacy/js-integrations "Device Mode Integrations (Legacy)" $integration_sdks_zip_file
./scripts/list-sdk-components.sh ${{ secrets.AWS_S3_BUCKET_NAME }} $s3_relative_path_prefix/modern/js-integrations $integration_sdks_html_file $integration_sdks_path_prefix/modern/js-integrations "Device Mode Integrations (Modern)" $integration_sdks_zip_file
# Generate the HTML file to list all the plugins
./scripts/list-sdk-components.sh ${{ secrets.AWS_S3_BUCKET_NAME }} $s3_relative_path_prefix/modern/plugins $plugins_html_file $plugins_path_prefix/modern/plugins "Plugins" $plugins_zip_file
# Copy all the HTML files to S3
aws s3 cp $integration_sdks_path_prefix/legacy/js-integrations/$integration_sdks_html_file $s3_path_prefix/legacy/js-integrations/$integration_sdks_html_file $copy_args
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/$integration_sdks_html_file $s3_path_prefix/modern/js-integrations/$integration_sdks_html_file $copy_args
aws s3 cp $plugins_path_prefix/modern/plugins/$plugins_html_file $s3_path_prefix/modern/plugins/$plugins_html_file $copy_args
- name: Create Cloudfront invalidation
- name: Invalidate CloudFront cache for all the SDK artifacts (versioned directory)
if: ${{ inputs.environment == 'production' }}
run: |
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/latest*"
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/${{ env.CURRENT_VERSION_VALUE }}/*"
- name: Send message to Slack channel
id: slack
Expand Down Expand Up @@ -306,57 +281,46 @@ jobs:
# Below steps are for v1.1 SDK (legacy)

- name: Sync files to S3 v1.1 directory
- name: Copy legacy SDK dependencies to S3
run: |
core_sdk_path_prefix="packages/analytics-v1.1/dist/cdn"
integration_sdks_path_prefix="packages/analytics-js-integrations/dist/cdn"
s3_path_prefix="s3://${{ secrets.AWS_S3_BUCKET_NAME }}/${{ inputs.s3_dir_path_legacy }}"
copy_args="--recursive --cache-control ${{ env.CACHE_CONTROL }}"
aws s3 cp $core_sdk_path_prefix/legacy/ $s3_path_prefix/ $copy_args
aws s3 cp $integration_sdks_path_prefix/legacy/js-integrations/ $s3_path_prefix/js-integrations/ $copy_args
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/ $s3_path_prefix/modern/js-integrations/ $copy_args
- name: Copy core legacy SDK artifacts to S3
run: |
core_sdk_path_prefix="packages/analytics-v1.1/dist/cdn"
s3_path_prefix="s3://${{ secrets.AWS_S3_BUCKET_NAME }}/${{ inputs.s3_dir_path_legacy }}"
copy_args="--recursive --cache-control ${{ env.CACHE_CONTROL }}"
aws s3 cp $core_sdk_path_prefix/legacy/ $s3_path_prefix/ $copy_args
aws s3 cp $core_sdk_path_prefix/modern/ $s3_path_prefix/modern/ $copy_args
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/ $s3_path_prefix/modern/js-integrations/ $copy_args
- name: Create Cloudfront invalidation
- name: Invalidate CloudFront cache for all the legacy SDK artifacts
run: |
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/${{ inputs.s3_dir_path_legacy }}*"
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/${{ inputs.s3_dir_path_legacy }}/*"
- name: Sync files to S3 v1.1 versioned directory
if: ${{ inputs.environment == 'production' }}
- name: Copy legacy SDK dependencies to S3 (versioned directory)
run: |
core_sdk_path_prefix="packages/analytics-v1.1/dist/cdn"
integration_sdks_path_prefix="packages/analytics-js-integrations/dist/cdn"
s3_path_prefix="s3://${{ secrets.AWS_S3_BUCKET_NAME }}/${{ env.CURRENT_VERSION_V1_VALUE }}"
copy_args="--recursive --cache-control ${{ env.CACHE_CONTROL }}"
aws s3 cp $core_sdk_path_prefix/legacy/ $s3_path_prefix/ $copy_args
aws s3 cp $integration_sdks_path_prefix/legacy/js-integrations/ $s3_path_prefix/js-integrations/ $copy_args
aws s3 cp $core_sdk_path_prefix/modern/ $s3_path_prefix/modern/ $copy_args
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/ $s3_path_prefix/modern/js-integrations/ $copy_args
- name: Create Cloudfront invalidation
if: ${{ inputs.environment == 'production' }}
run: |
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/${{ env.CURRENT_VERSION_V1_VALUE }}*"
- name: Sync files to S3 latest (v1.1)
if: ${{ inputs.environment == 'production' }}
- name: Copy core legacy SDK artifacts to S3 (versioned directory)
run: |
core_sdk_path_prefix="packages/analytics-v1.1/dist/cdn"
integration_sdks_path_prefix="packages/analytics-js-integrations/dist/cdn"
s3_path_prefix="s3://${{ secrets.AWS_S3_BUCKET_NAME }}/latest"
s3_path_prefix="s3://${{ secrets.AWS_S3_BUCKET_NAME }}/${{ env.CURRENT_VERSION_V1_VALUE }}"
copy_args="--recursive --cache-control ${{ env.CACHE_CONTROL }}"
aws s3 cp $core_sdk_path_prefix/legacy/ $s3_path_prefix/ $copy_args
aws s3 cp $integration_sdks_path_prefix/legacy/js-integrations/ $s3_path_prefix/js-integrations/ $copy_args
aws s3 cp $core_sdk_path_prefix/modern/ $s3_path_prefix/modern/ $copy_args
aws s3 cp $integration_sdks_path_prefix/modern/js-integrations/ $s3_path_prefix/modern/js-integrations/ $copy_args
- name: Create Cloudfront invalidation
if: ${{ inputs.environment == 'production' }}
- name: Invalidate CloudFront cache for all the legacy SDK artifacts (versioned directory)
run: |
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/latest*"
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/${{ env.CURRENT_VERSION_V1_VALUE }}/*"

0 comments on commit bf88dc5

Please sign in to comment.