ci: migrate docs + vrt websites from netlify to azure#5450
ci: migrate docs + vrt websites from netlify to azure#5450rubencarvalho merged 62 commits intomainfrom
Conversation
|
Tachometer resultsCurrently, no packages are changed by this PR... |
26c248d to
17651df
Compare
98e4da9 to
982025f
Compare
8f6eed3 to
ade5424
Compare
.circleci/config.yml
Outdated
| 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 |
There was a problem hiding this comment.
Can we add this in a retry loop to mitigate any flakiness?
rubencarvalho
left a comment
There was a problem hiding this comment.
Only really blocking thing is the auth method - great work here! 🚀
.github/workflows/preview-docs.yml
Outdated
| path: | | ||
| .cache/yarn | ||
| node_modules | ||
| key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }} |
There was a problem hiding this comment.
We probably want to also hash the package.json, in case it changes:
| key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }} | |
| key: ubuntu-latest-node20-${{ hashFiles('yarn.lock', 'package.json') }} |
.github/workflows/preview-docs.yml
Outdated
| - 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.github/workflows/preview-docs.yml
Outdated
| pr_hash="pr-${{ github.event.pull_request.number }}" | ||
| echo "hash=${pr_hash}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Install AzCopy |
There was a problem hiding this comment.
I see we're also installing AzCopy for this job, could we make this centralized and re-use in both places?
There was a problem hiding this comment.
Why do we need this? 🤔
There was a problem hiding this comment.
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.
.github/workflows/preview-docs.yml
Outdated
| # 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}" \ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
So many things went away 😮
Nice!
There was a problem hiding this comment.
Feels lighter. netli-bye
| ({ system, color, scale, direction, urlPath }) => { | ||
| const vrtUrl = `${baseUrl}/${prHash}/${urlPath}/review/`; | ||
|
|
||
| previewLinks.push(` |
There was a problem hiding this comment.
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\///') |
There was a problem hiding this comment.
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 😛
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
.circleci/config.yml
Outdated
| 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 |
There was a problem hiding this comment.
If we end up fetching the latest version, we can also use it here.
.circleci/config.yml
Outdated
| set +x | ||
|
|
||
| # Clean the SAS token (remove any whitespace/newlines) | ||
| CLEAN_SAS_TOKEN=$(echo "${AZURE_STORAGE_SAS_TOKEN}" | tr -d '\n\r\t ') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
.circleci/config.yml
Outdated
| # 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 |
There was a problem hiding this comment.
Is this necessary? Looks like we’re already setting these in the node environment.
There was a problem hiding this comment.
Also, single quotes here prevent variable expansion, so we’d just be writing the literal strings (e.g. $AZURE_CLIENT_ID) into $BASH_ENV.
TarunAdobe
left a comment
There was a problem hiding this comment.
APPROVAL GRANTED! IN FACT, APPROVAL ASCENDED TO MYTHICAL STATUS!
|
Superb work @TarunAdobe ! This needs a celebration. |
pfulton
left a comment
There was a problem hiding this comment.
@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. |
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
All documentation, Storybook, and VRT previews for PRs and beta builds are now deployed to Azure Blob Storage.
All preview URLs posted on PRs and in documentation have been updated to point to Azure.
CI/CD Pipeline Modernization
CircleCI config (.circleci/config.yml):
GitHub Actions:
Documentation and User-Facing Changes
Dependency and Cleanup
Motivation and context
Operational Benefits:
Related issue(s)
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Open a PR and verify that:
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