Skip to content

ci: migrate docs + vrt websites from netlify to azure#5450

Merged
rubencarvalho merged 62 commits intomainfrom
rajdeep/azure-circle-ci
Jun 25, 2025
Merged

ci: migrate docs + vrt websites from netlify to azure#5450
rubencarvalho merged 62 commits intomainfrom
rajdeep/azure-circle-ci

Conversation

@Rajdeepc
Copy link
Contributor

@Rajdeepc Rajdeepc commented May 7, 2025

Description

This PR migrates all preview deployments (documentation site, Storybook, and Visual Regression Tests) from Netlify to Azure Blob Storage for cost efficiency, and unified deployment strategy.
.
(JK, THE MAIN GOAL IS TO AVOID THE $20 BILL THAT JOSH IS PAYING OUT OF HIS OWN POCKET)
.
A quick overview of all the stuff I did in this PR

Key Changes:

Preview Deployments Now on Azure Blob Storage

CI/CD Pipeline Modernization

  • CircleCI config (.circleci/config.yml):

    • Adds an install-azcopy command for installing and authenticating AzCopy CLI.
    • Replaces all Netlify deployment steps with AzCopy uploads to Azure.
    • Updates the logic for determining the PR number and deployment path, closely mirroring GitHub Actions logic.
    • Removes Netlify and related deployment retries.
    • Lint and documentation jobs updated to streamline and target Azure deployment.
  • GitHub Actions:

    • Adds .github/actions/setup-azcopy composite action to set up AzCopy for workflows.
    • Adds .github/workflows/preview-docs.yml to build, deploy, and clean up PR documentation and Storybook on Azure.
    • Adds .github/workflows/trigger-ci-on-pr.yml to trigger CircleCI on PR open.
    • Updates .github/workflows/urls-smoke-test.yml to check Azure preview URLs and run smoke tests against them.

Documentation and User-Facing Changes

  • Preview URLs in documentation updated to point to Azure Blob Storage, e.g. the beta documentation link.
  • Automated PR comments now use Azure URLs for all previews (docs, Storybook, VRTs, and High Contrast Mode).
  • Playwright E2E tests updated to handle Azure URL structure (e.g., SWC_DIR path prefix).
  • Rollup config and asset URLs are now prefix-aware for Azure subdirectory deployments.

Dependency and Cleanup

  • Removes Netlify-specific scripts and dependencies (e.g., netlify-cli, Netlify deploy scripts, related code).
  • Cleans up preview quick-link assets and removes unused files.

Motivation and context

Operational Benefits:

  • Unified hosting on Azure for all preview artifacts.
  • Improved reliability and scalability, especially for PR and beta builds.
  • THE $20 BILL

Related issue(s)

  • SWC-900

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Open a PR and verify that:

    • Documentation and Storybook previews are posted as comments and accessible at the new Azure URLs.
    • Visual Regression Test (VRT) previews are available and updated for each PR.
    • Beta documentation is accessible at the new Azure location.
  • Ensure all CI jobs (CircleCI and GitHub Actions) succeed and the preview links are correct.

  • Check that all Netlify links/references are gone from docs and config.

  • Reviewers: See the posted PR comment for all preview links.

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

@changeset-bot
Copy link

changeset-bot bot commented May 7, 2025

⚠️ No Changeset found

Latest commit: a6b7ed9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2025

Tachometer results

Currently, no packages are changed by this PR...

@Rajdeepc Rajdeepc changed the title ci: upgraded to azure from netlify ci: migrate netlify to azure May 9, 2025
@TarunAdobe TarunAdobe force-pushed the rajdeep/azure-circle-ci branch 11 times, most recently from 26c248d to 17651df Compare May 22, 2025 06:06
@adobe adobe deleted a comment from github-actions bot May 22, 2025
@TarunAdobe TarunAdobe force-pushed the rajdeep/azure-circle-ci branch 5 times, most recently from 98e4da9 to 982025f Compare May 22, 2025 10:53
@adobe adobe deleted a comment from github-actions bot Jun 10, 2025
@adobe adobe deleted a comment from github-actions bot Jun 10, 2025
@adobe adobe deleted a comment from github-actions bot Jun 10, 2025
@adobe adobe deleted a comment from github-actions bot Jun 10, 2025
@adobe adobe deleted a comment from github-actions bot Jun 10, 2025
@TarunAdobe TarunAdobe force-pushed the rajdeep/azure-circle-ci branch 3 times, most recently from 8f6eed3 to ade5424 Compare June 10, 2025 07:12
@TarunAdobe TarunAdobe mentioned this pull request Jun 18, 2025
14 tasks
Copy link
Contributor Author

@Rajdeepc Rajdeepc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! I am happy that you have battle tested it. Feel free to get more reviews and feedback.

Comment on lines +166 to +170
wget -O azcopy.tar.gz https://github.com/Azure/azure-storage-azcopy/releases/download/v10.29.1/azcopy_linux_amd64_10.29.1.tar.gz
tar -xf azcopy.tar.gz --strip-components=1
chmod +x azcopy
export PATH=$PATH:$(pwd)
azcopy --version
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this in a retry loop to mitigate any flakiness?

Copy link
Contributor

@rubencarvalho rubencarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only really blocking thing is the auth method - great work here! 🚀

path: |
.cache/yarn
node_modules
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to also hash the package.json, in case it changes:

Suggested change
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }}
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock', 'package.json') }}

- name: Install AzCopy
run: |
# Download and install AzCopy
wget -O azcopy.tar.gz https://github.com/Azure/azure-storage-azcopy/releases/download/v10.29.1/azcopy_linux_amd64_10.29.1.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're hard-coding the AzCopy version here, but we have access to the latest releases, could we curl it and grep the platform we want?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only suggested this just seeing some cons which might introduced variability into our builds due to potential breakage if a release is pulled or changes format

pr_hash="pr-${{ github.event.pull_request.number }}"
echo "hash=${pr_hash}" >> $GITHUB_OUTPUT

- name: Install AzCopy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we're also installing AzCopy for this job, could we make this centralized and re-use in both places?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our current CircleCI workflow, jobs are triggered on every commit. However, the pull request (PR) number is only available in the environment after a PR is opened. This means that jobs initiated by pre-PR commits lack access to the PR context. As a result, we need to manually re-run the job after the PR is created to retrieve and utilize the PR number correctly.

# Upload Storybook
echo "Uploading Storybook to ${PR_HASH}/docs/storybook/"
azcopy copy "storybook-static/*" \
"https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/storybook/?${CLEAN_SAS_TOKEN}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not include the token here, please.
There are other ways of authenticating that do not require having the token potentially exposed like this, please take a look at using azcopy login with Azure AD credentials.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rubencarvalho given that we've done a few runs in this PR, do you think there's a need to preemptively rotate that token now?

I might be being a little unnecessarily cautious, so happy to take a "yes" or a "no" here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have migrated our scripts to authorize using a service principal by using a client secret instead of a SAS tokens so I can simply remove/delete that token to be safe!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So many things went away 😮
Nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels lighter. netli-bye

({ system, color, scale, direction, urlPath }) => {
const vrtUrl = `${baseUrl}/${prHash}/${urlPath}/review/`;

previewLinks.push(`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nitpicky, but can we push these links inline and then in the end we add the line breaks (${previewLinks.join('\n')})?

set +x
PR_NUMBER=""
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | sed 's/.*\/pull\///')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstance does this not exist? CIRCLE_PR_NUMBER shows to always be there. 🤔
I'd love to get rid of the complexity below 😛

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its flaky. i tested by making many prs and there were a total of 2 instances out of 7-8 where this didn't exist.
https://discuss.circleci.com/t/ci-pull-reuqest-and-other-pr-environment-variables-are-missing/38535
this has happened before and to a lot of many people so i wanted to avoid flakiness here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the context! I’m OK with keeping the fallback logic for now, but could we try to pinpoint when it is missing and follow up with CircleCI support?
For example, we know the PR-related env vars are only set when the build is part of a PR - could those failures have happened on a regular branch commit?

echo "Deployment failed after $max_attempts attempts."
exit 1
# Install AzCopy
wget -O azcopy.tar.gz https://github.com/Azure/azure-storage-azcopy/releases/download/v10.29.1/azcopy_linux_amd64_10.29.1.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we end up fetching the latest version, we can also use it here.

set +x

# Clean the SAS token (remove any whitespace/newlines)
CLEAN_SAS_TOKEN=$(echo "${AZURE_STORAGE_SAS_TOKEN}" | tr -d '\n\r\t ')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the comment below, let’s please switch to Azure AD-based auth here as well. SAS tokens are bearer tokens - anyone with the URL and token can access the blob, so they’re more risky to use in CI environments.

Copy link
Contributor Author

@Rajdeepc Rajdeepc Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure everyone can use it since circle CI will mask these tokens during build time. but its definitely a good practice to avoid leaks.

Comment on lines +47 to +52
# Set up Azure authentication
echo 'export AZCOPY_AUTO_LOGIN_TYPE="SPN"' >> $BASH_ENV
echo 'export AZCOPY_SPA_APPLICATION_ID="$AZURE_CLIENT_ID"' >> $BASH_ENV
echo 'export AZCOPY_SPA_CLIENT_SECRET="$AZURE_CLIENT_SECRET"' >> $BASH_ENV
echo 'export AZCOPY_TENANT_ID="$AZURE_TENANT_ID"' >> $BASH_ENV
source $BASH_ENV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Looks like we’re already setting these in the node environment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, single quotes here prevent variable expansion, so we’d just be writing the literal strings (e.g. $AZURE_CLIENT_ID) into $BASH_ENV.

Copy link
Contributor

@rubencarvalho rubencarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor

@TarunAdobe TarunAdobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVAL GRANTED! IN FACT, APPROVAL ASCENDED TO MYTHICAL STATUS!

@Rajdeepc
Copy link
Contributor Author

Superb work @TarunAdobe ! This needs a celebration.

Copy link
Collaborator

@pfulton pfulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TarunAdobe would you mind taking checking on the beta URL? I tried hitting the URL in your original PR description (and then also tried putting the pr number in there and moving it around to different parts of the URL structure) and either I have the wrong URL or it didn't correctly deploy.

@TarunAdobe
Copy link
Contributor

@TarunAdobe would you mind taking checking on the beta URL? I tried hitting the URL in your original PR description (and then also tried putting the pr number in there and moving it around to different parts of the URL structure) and either I have the wrong URL or it didn't correctly deploy.

@pfulton Beta docs deploy only happens on main branch. so that link won't be accessible until this pr gets merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants