-
Notifications
You must be signed in to change notification settings - Fork 227
ci: deploy vrts on main branch correctly #5569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,44 +131,43 @@ commands: | |
when: always | ||
name: Deploy VRT Results to Azure Blob Storage | ||
command: | | ||
# Get PR number from CircleCI environment | ||
PR_NUMBER="" | ||
if [ -n "$CIRCLE_PULL_REQUEST" ]; then | ||
PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | sed 's/.*\/pull\///') | ||
echo "Deploying VRT for PR #$PR_NUMBER" | ||
elif [ -n "$CIRCLE_PR_NUMBER" ]; then | ||
PR_NUMBER="$CIRCLE_PR_NUMBER" | ||
echo "Deploying VRT for PR #$PR_NUMBER" | ||
elif [[ "$CIRCLE_BRANCH" =~ ^pull/[0-9]+$ ]]; then | ||
PR_NUMBER=$(echo $CIRCLE_BRANCH | sed 's/pull\///') | ||
echo "Deploying VRT for forked PR #$PR_NUMBER" | ||
elif [ -n "$GITHUB_TOKEN" ]; then | ||
# GitHub API fallback | ||
PR_NUMBER=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" \ | ||
| grep -o '"number":[0-9]*' | head -1 | sed 's/"number"://') | ||
|
||
if [ -n "$PR_NUMBER" ]; then | ||
echo "Deploying VRT for PR #$PR_NUMBER (via GitHub API)" | ||
# Set deployment path based on branch | ||
if [ "$CIRCLE_BRANCH" = "ttomar/vrts-main" ]; then | ||
PR_HASH="main" | ||
echo "Deploying VRT for main branch to main path" | ||
else | ||
# Get PR number from CircleCI environment | ||
PR_NUMBER="" | ||
if [ -n "$CIRCLE_PULL_REQUEST" ]; then | ||
PR_NUMBER=$(echo "$CIRCLE_PULL_REQUEST" | sed 's/.*\/pull\///') | ||
echo "Deploying VRT for PR #$PR_NUMBER" | ||
elif [ -n "$CIRCLE_PR_NUMBER" ]; then | ||
PR_NUMBER="$CIRCLE_PR_NUMBER" | ||
echo "Deploying VRT for PR #$PR_NUMBER" | ||
elif [[ "$CIRCLE_BRANCH" =~ ^pull/[0-9]+$ ]]; then | ||
PR_NUMBER=$(echo "$CIRCLE_BRANCH" | sed 's/pull\///') | ||
echo "Deploying VRT for forked PR #$PR_NUMBER" | ||
elif [ -n "$GITHUB_TOKEN" ]; then | ||
# GitHub API fallback | ||
PR_NUMBER=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub allows multiple PRs from different forks to use the same branch name.This can cause the query to match a different PR from a different user, leading to incorrect PR numbers being picked. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't run circleci on forked branches |
||
| grep -o '"number":[0-9]*' | head -1 | sed 's/"number"://') | ||
|
||
if [ -n "$PR_NUMBER" ]; then | ||
echo "Deploying VRT for PR #$PR_NUMBER (via GitHub API)" | ||
else | ||
echo "⏭️ No PR found - skipping VRT deployment" | ||
exit 0 | ||
fi | ||
else | ||
echo "⏭️ No PR found - skipping VRT deployment" | ||
echo "⏭️ No PR detected - skipping VRT deployment" | ||
exit 0 | ||
fi | ||
else | ||
echo "⏭️ No PR detected - skipping VRT deployment" | ||
exit 0 | ||
fi | ||
|
||
# Only proceed if we have a valid PR number | ||
if [ -z "$PR_NUMBER" ]; then | ||
echo "⏭️ No PR number available - skipping VRT deployment" | ||
exit 0 | ||
PR_HASH="pr-${PR_NUMBER}" | ||
fi | ||
|
||
# Create PR hash using just PR number for overwriting deployments | ||
PR_HASH="pr-${PR_NUMBER}" | ||
|
||
# VRT combination for subdirectory | ||
combination="<< parameters.regression_system >>-<< parameters.regression_color >>-<< parameters.regression_scale >>-<< parameters.regression_dir >>" | ||
|
||
|
@@ -281,6 +280,9 @@ jobs: | |
- run: | ||
name: Move CEM to Storybook directory | ||
command: cp projects/documentation/custom-elements.json storybook/ | ||
- run: | ||
name: Build documentation with path prefix | ||
command: echo "SWC_DIR=beta/docs" >> $BASH_ENV | ||
- run: | ||
name: Build documentation | ||
command: yarn docs:build | ||
|
@@ -357,45 +359,43 @@ jobs: | |
when: always | ||
name: Deploy Visual Tests to Azure Blob Storage | ||
command: | | ||
# Get PR number from CircleCI environment | ||
set +x | ||
PR_NUMBER="" | ||
if [ -n "$CIRCLE_PULL_REQUEST" ]; then | ||
PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | sed 's/.*\/pull\///') | ||
echo "Deploying HCM VRT for PR #$PR_NUMBER" | ||
elif [ -n "$CIRCLE_PR_NUMBER" ]; then | ||
PR_NUMBER="$CIRCLE_PR_NUMBER" | ||
echo "Deploying HCM VRT for PR #$PR_NUMBER" | ||
elif [[ "$CIRCLE_BRANCH" =~ ^pull/[0-9]+$ ]]; then | ||
PR_NUMBER=$(echo $CIRCLE_BRANCH | sed 's/pull\///') | ||
echo "Deploying HCM VRT for forked PR #$PR_NUMBER" | ||
elif [ -n "$GITHUB_TOKEN" ]; then | ||
# GitHub API fallback | ||
PR_NUMBER=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" \ | ||
| grep -o '"number":[0-9]*' | head -1 | sed 's/"number"://') | ||
|
||
if [ -n "$PR_NUMBER" ]; then | ||
echo "Deploying HCM VRT for PR #$PR_NUMBER (via GitHub API)" | ||
# Set deployment path based on branch | ||
if [ "$CIRCLE_BRANCH" = "ttomar/vrts-main" ]; then | ||
PR_HASH="main" | ||
echo "Deploying HCM VRT for main branch to main path" | ||
else | ||
# Get PR number from CircleCI environment | ||
PR_NUMBER="" | ||
if [ -n "$CIRCLE_PULL_REQUEST" ]; then | ||
PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | sed 's/.*\/pull\///') | ||
echo "Deploying HCM VRT for PR #$PR_NUMBER" | ||
elif [ -n "$CIRCLE_PR_NUMBER" ]; then | ||
PR_NUMBER="$CIRCLE_PR_NUMBER" | ||
echo "Deploying HCM VRT for PR #$PR_NUMBER" | ||
elif [[ "$CIRCLE_BRANCH" =~ ^pull/[0-9]+$ ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we dont run circleci on forks so idt we need to worry abt this |
||
PR_NUMBER=$(echo "$CIRCLE_BRANCH" | sed 's/pull\///') | ||
echo "Deploying HCM VRT for forked PR #$PR_NUMBER" | ||
elif [ -n "$GITHUB_TOKEN" ]; then | ||
# GitHub API fallback | ||
PR_NUMBER=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" \ | ||
| grep -o '"number":[0-9]*' | head -1 | sed 's/"number"://') | ||
|
||
if [ -n "$PR_NUMBER" ]; then | ||
echo "Deploying HCM VRT for PR #$PR_NUMBER (via GitHub API)" | ||
else | ||
echo "⏭️ No PR found - skipping HCM VRT deployment" | ||
exit 0 | ||
fi | ||
else | ||
echo "⏭️ No PR found - skipping HCM VRT deployment" | ||
echo "⏭️ No PR detected - skipping HCM VRT deployment" | ||
exit 0 | ||
fi | ||
else | ||
echo "⏭️ No PR detected - skipping HCM VRT deployment" | ||
exit 0 | ||
fi | ||
|
||
# Only proceed if we have a valid PR number | ||
if [ -z "$PR_NUMBER" ]; then | ||
echo "⏭️ No PR number available - skipping HCM VRT deployment" | ||
exit 0 | ||
PR_HASH="pr-${PR_NUMBER}" | ||
fi | ||
|
||
# Create PR hash using just PR number for overwriting deployments | ||
PR_HASH="pr-${PR_NUMBER}" | ||
|
||
# Prepare files for deployment | ||
cp projects/documentation/content/favicon.ico test/visual/ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line assumes a format that may not always hold.
CIRCLE_BRANCH
for forked PRs is typically the branch name of the fork, notpull/xxx
. You can consider removing if this condition even triggers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont run circleci on forks so idt we need to worry abt this