File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1212permissions :
13- contents : write
13+ contents : read
1414 pages : write
1515 id-token : write
1616 pull-requests : write
@@ -21,7 +21,8 @@ concurrency:
2121 cancel-in-progress : true
2222
2323jobs :
24- deploy-preview :
24+ # Build job
25+ build :
2526 runs-on : ubuntu-latest
2627 # Don't run on closed PRs
2728 if : github.event.action != 'closed'
@@ -57,15 +58,20 @@ jobs:
5758 exit 1
5859 fi
5960
60- # Deploy to GitHub Pages in a PR-specific directory
61- - name : Deploy PR Preview
62- uses : JamesIves/github-pages-deploy-action@v4
61+ # Create PR-specific directory structure
62+ - name : Create PR-specific directory
63+ run : |
64+ mkdir -p pr-preview
65+ cp -r apps/docs/storybook-static pr-preview/pr-${{ github.event.pull_request.number }}
66+
67+ - name : Setup Pages
68+ uses : actions/configure-pages@v5
69+
70+ - name : Upload artifact
71+ uses : actions/upload-pages-artifact@v3
6372 with :
64- folder : apps/docs/storybook-static
65- target-folder : pr-preview/pr-${{ github.event.pull_request.number }}
66- clean : true
67- clean-exclude : |
68- pr-preview/pr-*
73+ path : pr-preview
74+ retention-days : 30
6975
7076 # Add a comment to the PR with the preview URL
7177 - name : Comment PR
@@ -108,6 +114,20 @@ jobs:
108114 });
109115 }
110116
117+ # Deploy job
118+ deploy :
119+ needs : build
120+ runs-on : ubuntu-latest
121+ if : github.event.action != 'closed'
122+ environment :
123+ name : github-pages
124+ url : ${{ steps.deployment.outputs.page_url }}
125+
126+ steps :
127+ - name : Deploy to GitHub Pages
128+ id : deployment
129+ uses : actions/deploy-pages@v4
130+
111131 # Clean up when PR is closed
112132 cleanup :
113133 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ The PR preview system:
35351 . Builds the Storybook documentation for each PR
36362 . Deploys it to a PR-specific directory on the ` gh-pages ` branch
37373 . Adds a comment to the PR with a link to the preview
38- 4 . Automatically updates the preview when you push new changes to the PR
38+ 4 . ** Automatically updates the preview when you push new changes to the PR**
39395 . Cleans up the preview when the PR is closed
4040
4141#### Troubleshooting PR Previews
You can’t perform that action at this time.
0 commit comments