Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/scripts/build-preview-urls-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ export const buildPreviewURLComment = (prNumber) => {
- [High Contrast Mode | Medium | LTR](${hcmUrl})`);

// Documentation and Storybook URLs
const docsUrl = `${baseUrl}/${prHash}/docs/`;
const storybookUrl = `${baseUrl}/${prHash}/docs/storybook/`;
const docsFirstGenUrl = `${baseUrl}/${prHash}/docs/first-gen-docs/`;
const storybookFirstGenUrl = `${baseUrl}/${prHash}/docs/first-gen-storybook/`;
const storybookSecondGenUrl = `${baseUrl}/${prHash}/docs/second-gen-storybook/`;

let comment = `## 📚 Branch Preview
let comment = `## 📚 Branch Preview Links

- [Documentation Site](${docsUrl})
- [Storybook](${storybookUrl})
- [Documentation Site (first-gen)](${docsFirstGenUrl})
- [Storybook (first-gen)](${storybookFirstGenUrl})
- [Storybook (second-gen)](${storybookSecondGenUrl})

<h3><strong>🔍 Visual Regression Test Results</strong></h3>
<h3><strong>🔍 First Generation Visual Regression Test Results</strong></h3>

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Expand Down
288 changes: 151 additions & 137 deletions .github/workflows/preview-docs.yml
Original file line number Diff line number Diff line change
@@ -1,146 +1,160 @@
name: Preview Documentation (Azure Blob Storage)

on:
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- "**"
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- '**'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think the preview docs action was failing because of all of the whitespace/indentations in this file? (yaml is white space-sensitive, correct?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ill investigate why my system is applying the white space. thats for calling this out

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it linting updates? That's just sort of what it looks like to me. 🤷‍♀️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah its definitely linting related but not sure why its getting applied now. ill check other yaml files too because those didnt get effected the same maybe?


permissions:
contents: read
pull-requests: write
contents: read
pull-requests: write

env:
AZCOPY_AUTO_LOGIN_TYPE: SPN
AZCOPY_SPA_APPLICATION_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZCOPY_SPA_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZCOPY_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZCOPY_AUTO_LOGIN_TYPE: SPN
AZCOPY_SPA_APPLICATION_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZCOPY_SPA_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZCOPY_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}

jobs:
build_and_deploy_job:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
runs-on: ubuntu-latest
name: Build and Deploy Job
outputs:
doc_url: ${{ steps.deploy.outputs.docs_url }}
steps:
## --- SETUP --- ##
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node LTS version
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn

- name: Enable Corepack
run: corepack enable

- name: Generate PR hash
id: pr_hash
run: |
# Use just PR number so each commit overwrites the previous deployment
pr_hash="pr-${{ github.event.pull_request.number }}"
echo "hash=${pr_hash}" >> "$GITHUB_OUTPUT"
echo "Generated PR hash: ${pr_hash}"
## --- YARN CACHE --- ##
- name: Check for cached dependencies
continue-on-error: true
id: cache-dependencies
uses: actions/cache@v4
with:
path: |
.cache/yarn
node_modules
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock', 'package.json') }}

## --- INSTALL & BUILD --- ##
- name: Install dependencies
shell: bash
run: yarn install --immutable

- name: Build 1st-gen
run: yarn workspace @spectrum-web-components/1st-gen build

- name: Build 2nd-gen core
run: yarn workspace @spectrum-web-components/core build

- name: Build 2nd-gen swc
run: yarn workspace @adobe/swc build

- name: Generate Custom Elements Manifest
run: yarn workspace @spectrum-web-components/1st-gen docs:analyze

- name: Move CEM to Storybook directory
run: cp 1st-gen/projects/documentation/custom-elements.json 1st-gen/storybook/

- name: Build documentation with path prefix
env:
SWC_DIR: ${{ steps.pr_hash.outputs.hash }}/docs
run: |
yarn workspace @spectrum-web-components/1st-gen docs:build
- name: Build Storybook
run: yarn workspace @spectrum-web-components/1st-gen storybook:build

## --- DEPLOY TO AZURE BLOB STORAGE --- ##
- name: Setup AzCopy
uses: ./.github/actions/setup-azcopy

- name: Deploy to Azure Blob Storage
id: deploy
env:
PR_HASH: ${{ steps.pr_hash.outputs.hash }}
run: |
# Upload documentation
echo "Uploading documentation to ${PR_HASH}/docs/"
azcopy copy "1st-gen/projects/documentation/dist/*" \
"https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/" \
--recursive \
--from-to LocalBlob
# Upload Storybook
echo "Uploading Storybook to ${PR_HASH}/docs/storybook/"
azcopy copy "1st-gen/storybook-static/*" \
"https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/storybook/" \
--recursive \
--from-to LocalBlob
# Set output URLs
docs_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/"
storybook_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/storybook/"
echo "docs_url=${docs_url}" >> "$GITHUB_OUTPUT"
echo "storybook_url=${storybook_url}" >> "$GITHUB_OUTPUT"
echo "Deployed to: ${docs_url}"
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Clean up PR deployment
steps:
- name: Check out code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Generate PR hash
id: pr_hash
run: |
# Create the same hash as in the deploy job
pr_hash="pr-${{ github.event.pull_request.number }}"
echo "hash=${pr_hash}" >> "$GITHUB_OUTPUT"
- name: Setup AzCopy
uses: ./.github/actions/setup-azcopy

- name: Clean up PR deployment
env:
PR_HASH: ${{ steps.pr_hash.outputs.hash }}
run: |
echo "Cleaning up deployment: ${PR_HASH}/"
azcopy remove "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/" \
--recursive || echo "Cleanup completed (some files may not exist)"
echo "Cleanup completed for PR deployment: ${PR_HASH}/"
build_and_deploy_job:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
runs-on: ubuntu-latest
name: Build and Deploy Job
outputs:
doc_url: ${{ steps.deploy.outputs.first-gen-docs_url }}
steps:
## --- SETUP --- ##
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node LTS version
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn

- name: Enable Corepack
run: corepack enable

- name: Generate PR hash
id: pr_hash
run: |
# Use just PR number so each commit overwrites the previous deployment
pr_hash="pr-${{ github.event.pull_request.number }}"
echo "hash=${pr_hash}" >> "$GITHUB_OUTPUT"
echo "Generated PR hash: ${pr_hash}"
## --- YARN CACHE --- ##
- name: Check for cached dependencies
continue-on-error: true
id: cache-dependencies
uses: actions/cache@v4
with:
path: |
.cache/yarn
node_modules
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock', 'package.json') }}

## --- INSTALL & BUILD --- ##
- name: Install dependencies
shell: bash
run: yarn install --immutable

- name: Build all generations
run: yarn build

- name: Generate Custom Elements Manifest
run: yarn workspace @spectrum-web-components/1st-gen docs:analyze

- name: Move CEM to Storybook directory
run: cp 1st-gen/projects/documentation/custom-elements.json 1st-gen/storybook/

- name: Build documentation with path prefix
env:
SWC_DIR: ${{ steps.pr_hash.outputs.hash }}/docs/first-gen-docs
run: |
yarn workspace @spectrum-web-components/1st-gen docs:build
- name: Build first-gen Storybook
run: yarn workspace @spectrum-web-components/1st-gen storybook:build

- name: Build second-gen Storybook
run: yarn workspace @spectrum-web-components/2nd-gen storybook:build

## --- DEPLOY TO AZURE BLOB STORAGE --- ##
- name: Setup AzCopy
uses: ./.github/actions/setup-azcopy

- name: Deploy to Azure Blob Storage
id: deploy
env:
PR_HASH: ${{ steps.pr_hash.outputs.hash }}
run: |
# Upload documentation
echo "Uploading first-gen documentation to ${PR_HASH}/docs/first-gen-docs/"
azcopy copy "1st-gen/projects/documentation/dist/*" \
"https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/first-gen-docs/" \
--recursive \
--from-to LocalBlob
# Upload first-gen Storybook
echo "Uploading first-gen Storybook to ${PR_HASH}/docs/first-gen-storybook/"
azcopy copy "1st-gen/projects/documentation/dist/storybook/*" \
"https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/first-gen-storybook/" \
--recursive \
--from-to LocalBlob
# Upload second-gen Storybook
echo "Uploading second-gen Storybook to ${PR_HASH}/docs/second-gen-storybook/"
azcopy copy "2nd-gen/packages/swc/storybook-static/*" \
"https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/second-gen-storybook/" \
--recursive \
--from-to LocalBlob
# Set output URLs
echo "Setting first_gen_docs_url..."
first_gen_docs_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/first-gen-docs"
echo "first_gen_docs_url=${first_gen_docs_url}" >> "$GITHUB_OUTPUT"
echo "Setting first_gen_storybook_url..."
first_gen_storybook_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/first-gen-storybook"
echo "first_gen_storybook_url=${first_gen_storybook_url}" >> "$GITHUB_OUTPUT"
echo "Setting second_gen_storybook_url..."
second_gen_storybook_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/second-gen-storybook"
echo "second_gen_storybook_url=${second_gen_storybook_url}" >> "$GITHUB_OUTPUT"
echo "Deployed to: ${first_gen_docs_url}"
echo "Deployed to: ${first_gen_storybook_url}"
echo "Deployed to: ${second_gen_storybook_url}"
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Clean up PR deployment
steps:
- name: Check out code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Generate PR hash
id: pr_hash
run: |
# Create the same hash as in the deploy job
pr_hash="pr-${{ github.event.pull_request.number }}"
echo "hash=${pr_hash}" >> "$GITHUB_OUTPUT"
- name: Setup AzCopy
uses: ./.github/actions/setup-azcopy

- name: Clean up PR deployment
env:
PR_HASH: ${{ steps.pr_hash.outputs.hash }}
run: |
echo "Cleaning up deployment: ${PR_HASH}/"
azcopy remove "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/" \
--recursive || echo "Cleanup completed (some files may not exist)"
echo "Cleanup completed for PR deployment: ${PR_HASH}/"
Loading
Loading