|
1 | 1 | name: Preview Documentation (Azure Blob Storage) |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - types: [opened, synchronize, reopened, closed] |
6 | | - branches: |
7 | | - - "**" |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, closed] |
| 6 | + branches: |
| 7 | + - '**' |
8 | 8 |
|
9 | 9 | permissions: |
10 | | - contents: read |
11 | | - pull-requests: write |
| 10 | + contents: read |
| 11 | + pull-requests: write |
12 | 12 |
|
13 | 13 | env: |
14 | | - AZCOPY_AUTO_LOGIN_TYPE: SPN |
15 | | - AZCOPY_SPA_APPLICATION_ID: ${{ secrets.AZURE_CLIENT_ID }} |
16 | | - AZCOPY_SPA_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} |
17 | | - AZCOPY_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} |
| 14 | + AZCOPY_AUTO_LOGIN_TYPE: SPN |
| 15 | + AZCOPY_SPA_APPLICATION_ID: ${{ secrets.AZURE_CLIENT_ID }} |
| 16 | + AZCOPY_SPA_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} |
| 17 | + AZCOPY_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} |
18 | 18 |
|
19 | 19 | jobs: |
20 | | - build_and_deploy_job: |
21 | | - if: github.event_name == 'pull_request' && github.event.action != 'closed' |
22 | | - runs-on: ubuntu-latest |
23 | | - name: Build and Deploy Job |
24 | | - outputs: |
25 | | - doc_url: ${{ steps.deploy.outputs.docs_url }} |
26 | | - steps: |
27 | | - ## --- SETUP --- ## |
28 | | - - name: Check out code |
29 | | - uses: actions/checkout@v4 |
30 | | - with: |
31 | | - fetch-depth: 0 |
32 | | - |
33 | | - - name: Use Node LTS version |
34 | | - uses: actions/setup-node@v4 |
35 | | - with: |
36 | | - node-version: 20 |
37 | | - cache: yarn |
38 | | - |
39 | | - - name: Enable Corepack |
40 | | - run: corepack enable |
41 | | - |
42 | | - - name: Generate PR hash |
43 | | - id: pr_hash |
44 | | - run: | |
45 | | - # Use just PR number so each commit overwrites the previous deployment |
46 | | - pr_hash="pr-${{ github.event.pull_request.number }}" |
47 | | - echo "hash=${pr_hash}" >> "$GITHUB_OUTPUT" |
48 | | - echo "Generated PR hash: ${pr_hash}" |
49 | | -
|
50 | | - ## --- YARN CACHE --- ## |
51 | | - - name: Check for cached dependencies |
52 | | - continue-on-error: true |
53 | | - id: cache-dependencies |
54 | | - uses: actions/cache@v4 |
55 | | - with: |
56 | | - path: | |
57 | | - .cache/yarn |
58 | | - node_modules |
59 | | - key: ubuntu-latest-node20-${{ hashFiles('yarn.lock', 'package.json') }} |
60 | | - |
61 | | - ## --- INSTALL & BUILD --- ## |
62 | | - - name: Install dependencies |
63 | | - shell: bash |
64 | | - run: yarn install --immutable |
65 | | - |
66 | | - - name: Build 1st-gen |
67 | | - run: yarn workspace @spectrum-web-components/1st-gen build |
68 | | - |
69 | | - - name: Build 2nd-gen core |
70 | | - run: yarn workspace @spectrum-web-components/core build |
71 | | - |
72 | | - - name: Build 2nd-gen swc |
73 | | - run: yarn workspace @adobe/swc build |
74 | | - |
75 | | - - name: Generate Custom Elements Manifest |
76 | | - run: yarn workspace @spectrum-web-components/1st-gen docs:analyze |
77 | | - |
78 | | - - name: Move CEM to Storybook directory |
79 | | - run: cp 1st-gen/projects/documentation/custom-elements.json 1st-gen/storybook/ |
80 | | - |
81 | | - - name: Build documentation with path prefix |
82 | | - env: |
83 | | - SWC_DIR: ${{ steps.pr_hash.outputs.hash }}/docs |
84 | | - run: | |
85 | | - yarn workspace @spectrum-web-components/1st-gen docs:build |
86 | | -
|
87 | | - - name: Build Storybook |
88 | | - run: yarn workspace @spectrum-web-components/1st-gen storybook:build |
89 | | - |
90 | | - ## --- DEPLOY TO AZURE BLOB STORAGE --- ## |
91 | | - - name: Setup AzCopy |
92 | | - uses: ./.github/actions/setup-azcopy |
93 | | - |
94 | | - - name: Deploy to Azure Blob Storage |
95 | | - id: deploy |
96 | | - env: |
97 | | - PR_HASH: ${{ steps.pr_hash.outputs.hash }} |
98 | | - run: | |
99 | | - # Upload documentation |
100 | | - echo "Uploading documentation to ${PR_HASH}/docs/" |
101 | | - azcopy copy "1st-gen/projects/documentation/dist/*" \ |
102 | | - "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/" \ |
103 | | - --recursive \ |
104 | | - --from-to LocalBlob |
105 | | -
|
106 | | - # Upload Storybook |
107 | | - echo "Uploading Storybook to ${PR_HASH}/docs/storybook/" |
108 | | - azcopy copy "1st-gen/storybook-static/*" \ |
109 | | - "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/storybook/" \ |
110 | | - --recursive \ |
111 | | - --from-to LocalBlob |
112 | | -
|
113 | | - # Set output URLs |
114 | | - docs_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/" |
115 | | - storybook_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/storybook/" |
116 | | - echo "docs_url=${docs_url}" >> "$GITHUB_OUTPUT" |
117 | | - echo "storybook_url=${storybook_url}" >> "$GITHUB_OUTPUT" |
118 | | - echo "Deployed to: ${docs_url}" |
119 | | -
|
120 | | - close_pull_request_job: |
121 | | - if: github.event_name == 'pull_request' && github.event.action == 'closed' |
122 | | - runs-on: ubuntu-latest |
123 | | - name: Clean up PR deployment |
124 | | - steps: |
125 | | - - name: Check out code |
126 | | - uses: actions/checkout@v5 |
127 | | - with: |
128 | | - fetch-depth: 0 |
129 | | - - name: Generate PR hash |
130 | | - id: pr_hash |
131 | | - run: | |
132 | | - # Create the same hash as in the deploy job |
133 | | - pr_hash="pr-${{ github.event.pull_request.number }}" |
134 | | - echo "hash=${pr_hash}" >> "$GITHUB_OUTPUT" |
135 | | -
|
136 | | - - name: Setup AzCopy |
137 | | - uses: ./.github/actions/setup-azcopy |
138 | | - |
139 | | - - name: Clean up PR deployment |
140 | | - env: |
141 | | - PR_HASH: ${{ steps.pr_hash.outputs.hash }} |
142 | | - run: | |
143 | | - echo "Cleaning up deployment: ${PR_HASH}/" |
144 | | - azcopy remove "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/" \ |
145 | | - --recursive || echo "Cleanup completed (some files may not exist)" |
146 | | - echo "Cleanup completed for PR deployment: ${PR_HASH}/" |
| 20 | + build_and_deploy_job: |
| 21 | + if: github.event_name == 'pull_request' && github.event.action != 'closed' |
| 22 | + runs-on: ubuntu-latest |
| 23 | + name: Build and Deploy Job |
| 24 | + outputs: |
| 25 | + doc_url: ${{ steps.deploy.outputs.docs_url }} |
| 26 | + steps: |
| 27 | + ## --- SETUP --- ## |
| 28 | + - name: Check out code |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + |
| 33 | + - name: Use Node LTS version |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: 20 |
| 37 | + cache: yarn |
| 38 | + |
| 39 | + - name: Enable Corepack |
| 40 | + run: corepack enable |
| 41 | + |
| 42 | + - name: Generate PR hash |
| 43 | + id: pr_hash |
| 44 | + run: | |
| 45 | + # Use just PR number so each commit overwrites the previous deployment |
| 46 | + pr_hash="pr-${{ github.event.pull_request.number }}" |
| 47 | + echo "hash=${pr_hash}" >> "$GITHUB_OUTPUT" |
| 48 | + echo "Generated PR hash: ${pr_hash}" |
| 49 | +
|
| 50 | + ## --- YARN CACHE --- ## |
| 51 | + - name: Check for cached dependencies |
| 52 | + continue-on-error: true |
| 53 | + id: cache-dependencies |
| 54 | + uses: actions/cache@v4 |
| 55 | + with: |
| 56 | + path: | |
| 57 | + .cache/yarn |
| 58 | + node_modules |
| 59 | + key: ubuntu-latest-node20-${{ hashFiles('yarn.lock', 'package.json') }} |
| 60 | + |
| 61 | + ## --- INSTALL & BUILD --- ## |
| 62 | + - name: Install dependencies |
| 63 | + shell: bash |
| 64 | + run: yarn install --immutable |
| 65 | + |
| 66 | + - name: Build 1st-gen |
| 67 | + run: yarn workspace @spectrum-web-components/1st-gen build |
| 68 | + |
| 69 | + - name: Build 2nd-gen core |
| 70 | + run: yarn workspace @spectrum-web-components/core build |
| 71 | + |
| 72 | + - name: Build 2nd-gen swc |
| 73 | + run: yarn workspace @adobe/swc build |
| 74 | + |
| 75 | + - name: Generate Custom Elements Manifest |
| 76 | + run: yarn workspace @spectrum-web-components/1st-gen docs:analyze |
| 77 | + |
| 78 | + - name: Move CEM to Storybook directory |
| 79 | + run: cp 1st-gen/projects/documentation/custom-elements.json 1st-gen/storybook/ |
| 80 | + |
| 81 | + - name: Build documentation with path prefix |
| 82 | + env: |
| 83 | + SWC_DIR: ${{ steps.pr_hash.outputs.hash }}/docs |
| 84 | + run: | |
| 85 | + yarn workspace @spectrum-web-components/1st-gen docs:build |
| 86 | +
|
| 87 | + - name: Build 1st-gen Storybook |
| 88 | + run: yarn workspace @spectrum-web-components/1st-gen storybook:build |
| 89 | + |
| 90 | + - name: Build 2nd-gen Storybook |
| 91 | + run: yarn workspace @spectrum-web-components/2nd-gen storybook:build |
| 92 | + |
| 93 | + ## --- DEPLOY TO AZURE BLOB STORAGE --- ## |
| 94 | + - name: Setup AzCopy |
| 95 | + uses: ./.github/actions/setup-azcopy |
| 96 | + |
| 97 | + - name: Deploy to Azure Blob Storage |
| 98 | + id: deploy |
| 99 | + env: |
| 100 | + PR_HASH: ${{ steps.pr_hash.outputs.hash }} |
| 101 | + run: | |
| 102 | + # Upload documentation |
| 103 | + echo "Uploading 1st-gen documentation to ${PR_HASH}/docs/1st-gen-docs/" |
| 104 | + azcopy copy "1st-gen/projects/documentation/dist/*" \ |
| 105 | + "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/1st-gen-docs/" \ |
| 106 | + --recursive \ |
| 107 | + --from-to LocalBlob |
| 108 | +
|
| 109 | + # Upload 1st-gen Storybook |
| 110 | + echo "Uploading 1st-gen Storybook to ${PR_HASH}/docs/1st-gen-storybook/" |
| 111 | + azcopy copy "1st-gen/storybook-static/*" \ |
| 112 | + "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/1st-gen-storybook/" \ |
| 113 | + --recursive \ |
| 114 | + --from-to LocalBlob |
| 115 | +
|
| 116 | + # Upload 2nd-gen Storybook |
| 117 | + echo "Uploading 2nd-gen Storybook to ${PR_HASH}/docs/2nd-gen-storybook/" |
| 118 | + azcopy copy "2nd-gen/packages/swc/storybook-static/*" \ |
| 119 | + "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/docs/2nd-gen-storybook/" \ |
| 120 | + --recursive \ |
| 121 | + --from-to LocalBlob |
| 122 | +
|
| 123 | + # Set output URLs |
| 124 | + 1st-gendocs_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/1st-gen-docs/" |
| 125 | + 1st-gen-storybook_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/1st-gen-storybook/" |
| 126 | + 2nd-gen-storybook_url="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/docs/2nd-gen-storybook/" |
| 127 | + echo "1st-gen-docs_url=${1st-gen-docs_url}" >> "$GITHUB_OUTPUT" |
| 128 | + echo "1st-gen-storybook_url=${1st-gen-storybook_url}" >> "$GITHUB_OUTPUT" |
| 129 | + echo "2nd-gen-storybook_url=${2nd-gen-storybook_url}" >> "$GITHUB_OUTPUT" |
| 130 | + echo "Deployed to: ${1st-gen-docs_url}" |
| 131 | + echo "Deployed to: ${1st-gen-storybook_url}" |
| 132 | + echo "Deployed to: ${2nd-gen-storybook_url}" |
| 133 | +
|
| 134 | + close_pull_request_job: |
| 135 | + if: github.event_name == 'pull_request' && github.event.action == 'closed' |
| 136 | + runs-on: ubuntu-latest |
| 137 | + name: Clean up PR deployment |
| 138 | + steps: |
| 139 | + - name: Check out code |
| 140 | + uses: actions/checkout@v5 |
| 141 | + with: |
| 142 | + fetch-depth: 0 |
| 143 | + - name: Generate PR hash |
| 144 | + id: pr_hash |
| 145 | + run: | |
| 146 | + # Create the same hash as in the deploy job |
| 147 | + pr_hash="pr-${{ github.event.pull_request.number }}" |
| 148 | + echo "hash=${pr_hash}" >> "$GITHUB_OUTPUT" |
| 149 | +
|
| 150 | + - name: Setup AzCopy |
| 151 | + uses: ./.github/actions/setup-azcopy |
| 152 | + |
| 153 | + - name: Clean up PR deployment |
| 154 | + env: |
| 155 | + PR_HASH: ${{ steps.pr_hash.outputs.hash }} |
| 156 | + run: | |
| 157 | + echo "Cleaning up deployment: ${PR_HASH}/" |
| 158 | + azcopy remove "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/" \ |
| 159 | + --recursive || echo "Cleanup completed (some files may not exist)" |
| 160 | + echo "Cleanup completed for PR deployment: ${PR_HASH}/" |
0 commit comments