|
58 | 58 | exit 1 |
59 | 59 | fi |
60 | 60 |
|
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 |
72 | | - with: |
73 | | - path: pr-preview |
74 | | - retention-days: 30 |
75 | | - |
76 | 61 | # Add a comment to the PR with the preview URL |
77 | 62 | - name: Comment PR |
78 | 63 | uses: actions/github-script@v6 |
|
81 | 66 | const previewUrl = `https://lambda-curry.github.io/forms/pr-preview/pr-${context.issue.number}/`; |
82 | 67 | const commentBody = `📝 **Storybook Preview**: [View Storybook](${previewUrl}) |
83 | 68 |
|
84 | | - This preview will be updated automatically when you push new changes to this PR.`; |
| 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.`; |
85 | 72 | |
86 | 73 | // Get existing comments |
87 | 74 | const comments = await github.rest.issues.listComments({ |
@@ -114,16 +101,35 @@ jobs: |
114 | 101 | }); |
115 | 102 | } |
116 | 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 | 117 | # Deploy job |
118 | 118 | deploy: |
119 | 119 | needs: build |
120 | 120 | runs-on: ubuntu-latest |
121 | 121 | if: github.event.action != 'closed' |
| 122 | + |
| 123 | + # Use a specific environment with protection rules |
| 124 | + # This ensures only approved PRs can deploy |
122 | 125 | environment: |
123 | | - name: github-pages |
| 126 | + name: pr-preview |
124 | 127 | url: ${{ steps.deployment.outputs.page_url }} |
125 | | - |
| 128 | + |
126 | 129 | steps: |
| 130 | + - name: Setup Pages |
| 131 | + uses: actions/configure-pages@v5 |
| 132 | + |
127 | 133 | - name: Deploy to GitHub Pages |
128 | 134 | id: deployment |
129 | 135 | uses: actions/deploy-pages@v4 |
|
0 commit comments