Skip to content

Commit dcd8e37

Browse files
authored
Merge pull request #1 from lambda-curry/feature/medusa-forms-migration
2 parents 4072fc0 + d28d5c7 commit dcd8e37

22 files changed

+879
-346
lines changed

.github/workflows/github-pages.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Single deploy job since we're just deploying
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v3
37+
with:
38+
node-version: '22.9.0'
39+
40+
- name: Setup Yarn Corepack
41+
run: corepack enable
42+
43+
- name: Install dependencies
44+
run: yarn install
45+
46+
- name: Build Storybook
47+
run: yarn build-storybook
48+
49+
- name: Setup Pages
50+
uses: actions/configure-pages@v5
51+
52+
- name: Upload artifact
53+
uses: actions/upload-pages-artifact@v3
54+
with:
55+
# Don't remove PR previews when deploying the main branch
56+
path: 'apps/docs/storybook-static'
57+
retention-days: 30
58+
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@v4
62+

.github/workflows/pr-preview.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: Deploy PR Preview
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- closed
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
pull-requests: write
17+
18+
# Allow only one concurrent deployment per PR
19+
concurrency:
20+
group: pr-preview-${{ github.event.pull_request.number }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
# Build job
25+
build:
26+
runs-on: ubuntu-latest
27+
# Don't run on closed PRs
28+
if: github.event.action != 'closed'
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v3
36+
with:
37+
node-version: '22.9.0'
38+
39+
- name: Setup Yarn Corepack
40+
run: corepack enable
41+
42+
- name: Install dependencies
43+
run: yarn install
44+
45+
- name: Build Storybook
46+
run: yarn build-storybook
47+
48+
# Verify the build output
49+
- name: Verify build output
50+
run: |
51+
echo "Checking build output directory..."
52+
ls -la apps/docs/storybook-static
53+
echo "Checking for index.html..."
54+
if [ -f apps/docs/storybook-static/index.html ]; then
55+
echo "index.html exists"
56+
else
57+
echo "index.html does not exist"
58+
exit 1
59+
fi
60+
61+
# Add a comment to the PR with the preview URL
62+
- name: Comment PR
63+
uses: actions/github-script@v6
64+
with:
65+
script: |
66+
const previewUrl = `https://lambda-curry.github.io/medusa-forms/pr-${context.issue.number}/`;
67+
const commentBody = `📝 **Storybook Preview**: [View Storybook](${previewUrl})
68+
69+
This preview will be updated automatically when you push new changes to this PR.
70+
71+
> Note: The preview will be available after the workflow completes and the PR is approved for deployment.`;
72+
73+
// Get existing comments
74+
const comments = await github.rest.issues.listComments({
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
issue_number: context.issue.number,
78+
});
79+
80+
// Check if we already have a comment
81+
const botComment = comments.data.find(comment =>
82+
comment.user.login === 'github-actions[bot]' &&
83+
comment.body.includes('Storybook Preview')
84+
);
85+
86+
if (botComment) {
87+
// Update existing comment
88+
await github.rest.issues.updateComment({
89+
owner: context.repo.owner,
90+
repo: context.repo.repo,
91+
comment_id: botComment.id,
92+
body: commentBody
93+
});
94+
} else {
95+
// Create new comment
96+
await github.rest.issues.createComment({
97+
owner: context.repo.owner,
98+
repo: context.repo.repo,
99+
issue_number: context.issue.number,
100+
body: commentBody
101+
});
102+
}
103+
104+
# Create PR-specific directory structure
105+
- name: Create PR-specific directory
106+
run: |
107+
mkdir -p pr-preview/pr-${{ github.event.pull_request.number }}
108+
cp -r apps/docs/storybook-static/* pr-preview/pr-${{ github.event.pull_request.number }}/
109+
110+
# Upload the artifact for the deployment job
111+
- name: Upload artifact
112+
uses: actions/upload-pages-artifact@v3
113+
with:
114+
path: pr-preview
115+
retention-days: 30
116+
117+
# Deploy job
118+
deploy:
119+
needs: build
120+
runs-on: ubuntu-latest
121+
if: github.event.action != 'closed'
122+
123+
# Use a specific environment with protection rules
124+
# This ensures only approved PRs can deploy
125+
environment:
126+
name: pr-preview
127+
url: ${{ steps.deployment.outputs.page_url }}
128+
129+
steps:
130+
- name: Setup Pages
131+
uses: actions/configure-pages@v5
132+
133+
- name: Deploy to GitHub Pages
134+
id: deployment
135+
uses: actions/deploy-pages@v4
136+
137+
# Clean up when PR is closed
138+
cleanup:
139+
runs-on: ubuntu-latest
140+
if: github.event.action == 'closed'
141+
permissions:
142+
contents: write
143+
144+
steps:
145+
- name: Checkout
146+
uses: actions/checkout@v4
147+
with:
148+
ref: gh-pages
149+
150+
- name: Delete PR Preview
151+
run: |
152+
PR_NUMBER="${{ github.event.pull_request.number }}"
153+
PR_PREVIEW_PATH="pr-preview/pr-$PR_NUMBER"
154+
155+
if [ -d "$PR_PREVIEW_PATH" ]; then
156+
echo "Removing PR preview at $PR_PREVIEW_PATH"
157+
rm -rf "$PR_PREVIEW_PATH"
158+
159+
# Commit and push the changes
160+
git config user.name "GitHub Actions"
161+
git config user.email "[email protected]"
162+
git add -A
163+
git commit -m "Remove PR preview for PR #$PR_NUMBER" || echo "No changes to commit"
164+
git push
165+
else
166+
echo "PR preview directory not found"
167+
fi
168+

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repo
16+
uses: actions/checkout@v3
17+
18+
- name: Setup Node.js 20.x
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: 20.x
22+
23+
- name: Enable Corepack
24+
run: corepack enable
25+
26+
- name: Install Correct Yarn Version
27+
run: corepack prepare [email protected] --activate
28+
29+
- name: Install Dependencies
30+
run: yarn
31+
32+
- name: Create Release Pull Request or Publish to npm
33+
id: changesets
34+
uses: changesets/action@v1
35+
with:
36+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
37+
publish: yarn release
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41+

.github/workflows/test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 15
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '22.9.0'
25+
26+
- name: Setup Yarn Corepack
27+
run: corepack enable
28+
29+
- name: Install dependencies
30+
run: yarn install
31+
32+
- uses: dtinth/setup-github-actions-caching-for-turbo@v1
33+
34+
- name: Build packages
35+
run: yarn build
36+
37+
- name: Build Storybook
38+
run: yarn build-storybook
39+
40+
- name: Lint and format check
41+
run: yarn format-and-lint
42+
43+
- name: Upload artifacts on failure
44+
if: failure()
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: test-failure
48+
path: apps/docs/storybook-static
49+
retention-days: 2
50+

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
"source.fixAll.biome": "explicit",
2323
"source.organizeImports.biome": "explicit"
2424
},
25-
"tailwindCSS.classAttributes": ["class", "className", "ngClass", "class:list", "wrapperClassName"]
25+
"tailwindCSS.classAttributes": ["class", "className", "ngClass", "class:list", "wrapperClassName"],
26+
"[json]": {
27+
"editor.defaultFormatter": "biomejs.biome"
28+
}
2629
}

0 commit comments

Comments
 (0)