Skip to content

Commit 26c248d

Browse files
committed
ci: try commenting with azure
1 parent 9ff3885 commit 26c248d

File tree

2 files changed

+108
-53
lines changed

2 files changed

+108
-53
lines changed

.circleci/config.yml

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -249,54 +249,6 @@ jobs:
249249
name: Are there changes?
250250
command: git diff-files --exit-code
251251

252-
preview-docs:
253-
executor: azure
254-
steps:
255-
- downstream
256-
- run:
257-
name: Generate Custom Elements Manifest
258-
command: yarn docs:analyze
259-
- run:
260-
name: Move CEM to Storybook directory
261-
command: cp projects/documentation/custom-elements.json storybook/
262-
- run:
263-
name: Build documentation
264-
command: yarn docs:build
265-
- run:
266-
name: Build Storybook
267-
command: yarn storybook:build
268-
- run: echo '/* /index.html 200' > projects/documentation/dist/_redirects
269-
- run:
270-
name: Install Azure Static Web Apps CLI
271-
command: |
272-
echo "Installing Azure Static Web Apps CLI..."
273-
sudo npm install -g @azure/static-web-apps-cli
274-
- run:
275-
name: Deploy Documentation Site to Azure Static Web Apps
276-
command: |
277-
branch=$(git symbolic-ref --short HEAD)
278-
branch=$(npx slugify-cli $branch)
279-
max_attempts=3
280-
attempt=0
281-
282-
while [ $attempt -lt $max_attempts ]; do
283-
if npx swa deploy \
284-
--app-name my-docs-site \
285-
--resource-group swc-previews \
286-
--app-location projects/documentation/dist \
287-
--deployment-token $SWA_CLI_DEPLOYMENT_TOKEN; then
288-
echo "Deployment successful!"
289-
exit 0
290-
else
291-
attempt=$((attempt + 1))
292-
echo "Deploy failed, retrying ($attempt/$max_attempts)..."
293-
sleep 10
294-
fi
295-
done
296-
297-
echo "Deployment failed after $max_attempts attempts."
298-
exit 1
299-
300252
beta-docs:
301253
executor: azure
302254

@@ -448,11 +400,6 @@ workflows:
448400
branches:
449401
# Forked pull requests have CIRCLE_BRANCH set to pull/XXX
450402
ignore: /pull\/[0-9]+/
451-
- preview-docs:
452-
filters:
453-
branches:
454-
# Forked pull requests have CIRCLE_BRANCH set to pull/XXX
455-
ignore: /pull\/[0-9]+/
456403
- beta-docs:
457404
filters:
458405
branches:

.github/workflows/preview-docs.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Preview Documentation (Azure)
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, closed]
6+
branches:
7+
- '**'
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
build_and_deploy_job:
15+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
16+
runs-on: ubuntu-latest
17+
name: Build and Deploy Job
18+
steps:
19+
## --- SETUP --- ##
20+
- name: Check out code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Use Node LTS version
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
cache: yarn
30+
31+
- name: Enable Corepack
32+
run: corepack enable
33+
34+
- name: Clean up comments from previous Azure deploys
35+
if: github.event_name == 'pull_request'
36+
shell: bash
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: |
40+
pr=${{ github.event.pull_request.number }}
41+
comments=$(gh api repos/${{ github.repository }}/issues/$pr/comments)
42+
echo "$comments" | jq -c '.[]' | while read -r comment; do
43+
body=$(echo "$comment" | jq -r '.body')
44+
id=$(echo "$comment" | jq -r '.id')
45+
if [[ "$body" == Azure\ Static\ Web\ Apps:* ]]; then
46+
echo "Deleting comment $id"
47+
gh api repos/${{ github.repository }}/issues/comments/$id -X DELETE
48+
fi
49+
done
50+
51+
## --- YARN CACHE --- ##
52+
- name: Check for cached dependencies
53+
continue-on-error: true
54+
id: cache-dependencies
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
.cache/yarn
59+
node_modules
60+
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }}
61+
62+
## --- INSTALL & BUILD --- ##
63+
- name: Install dependencies
64+
shell: bash
65+
run: yarn install --immutable
66+
67+
- name: Build
68+
run: yarn build
69+
70+
- name: Generate Custom Elements Manifest
71+
run: yarn docs:analyze
72+
73+
- name: Move CEM to Storybook directory
74+
run: cp projects/documentation/custom-elements.json storybook/
75+
76+
- name: Build documentation
77+
run: yarn docs:build
78+
79+
- name: Build Storybook
80+
run: yarn storybook:build
81+
82+
- name: Add redirects
83+
run: echo '/* /index.html 200' > projects/documentation/dist/_redirects
84+
85+
## --- DEPLOY --- ##
86+
- name: Deploy to Azure Static Web Apps
87+
id: builddeploy
88+
uses: Azure/static-web-apps-deploy@v1
89+
with:
90+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_PLANT_02F0C200F }}
91+
repo_token: ${{ secrets.GITHUB_TOKEN }}
92+
action: 'upload'
93+
app_location: 'projects/documentation/dist'
94+
api_location: ''
95+
output_location: ''
96+
timeout-minutes: 10
97+
98+
close_pull_request_job:
99+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
100+
runs-on: ubuntu-latest
101+
name: Clean up PR environment
102+
steps:
103+
- name: Remove PR environment
104+
id: closepullrequest
105+
uses: Azure/static-web-apps-deploy@v1
106+
with:
107+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_PLANT_02F0C200F }}
108+
action: 'close'

0 commit comments

Comments
 (0)