Skip to content

Commit d574d72

Browse files
feat(storybooks): use custom action for github pages deploy
Because: * custom actions bypasses the 10 builds per hour limit, according to github’s documentation This commit: * use custom action for github pages deploy instead of the gh-pages branch, using that branch as storage instead Closes #FXA-12879
1 parent 21275b2 commit d574d72

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

.github/workflows/deploy-storybooks.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ permissions:
1111
contents: write
1212
pull-requests: write
1313
statuses: write
14+
pages: write
15+
id-token: write
1416

1517
jobs:
1618
build:
@@ -84,11 +86,13 @@ jobs:
8486
path: deploy/
8587
retention-days: 1
8688

87-
deploy:
88-
name: Deploy to GitHub Pages
89+
prepare:
90+
name: Prepare Storybooks for Deployment
8991
runs-on: ubuntu-latest
9092
needs: build
9193
if: needs.build.outputs.has_storybooks == 'true'
94+
outputs:
95+
deploy_dir: ${{ steps.deploy-dir.outputs.path }}
9296
# Single concurrency group to prevent conflicts
9397
concurrency:
9498
group: gh-pages-deploy
@@ -135,16 +139,16 @@ jobs:
135139
REPO_NAME: ${{ github.event.repository.name }}
136140
REPO_OWNER: ${{ github.repository_owner }}
137141

138-
- name: Commit and push to gh-pages
142+
- name: Update gh-pages branch for artifact storage
139143
run: |
140144
cd gh-pages
141145
git config user.name "github-actions[bot]"
142146
git config user.email "github-actions[bot]@users.noreply.github.com"
143147
144148
if [ "${{ github.event_name }}" == "pull_request" ]; then
145-
COMMIT_MSG="Deploy storybooks for PR ${{ github.event.pull_request.number }}"
149+
COMMIT_MSG="Store storybooks for PR ${{ github.event.pull_request.number }}"
146150
else
147-
COMMIT_MSG="Deploy storybooks from main branch"
151+
COMMIT_MSG="Store storybooks from main branch"
148152
fi
149153
150154
# Create orphan branch (no history) with current content
@@ -155,12 +159,28 @@ jobs:
155159
# Replace gh-pages with the new orphan branch
156160
git push --force origin gh-pages-new:gh-pages
157161
162+
- name: Upload GitHub Pages artifact
163+
uses: actions/upload-pages-artifact@v3
164+
with:
165+
path: gh-pages/
166+
167+
deploy:
168+
name: Deploy to GitHub Pages
169+
runs-on: ubuntu-latest
170+
needs: [build, prepare]
171+
if: needs.build.outputs.has_storybooks == 'true'
172+
continue-on-error: true
173+
steps:
174+
- name: Deploy to GitHub Pages
175+
id: deployment
176+
uses: actions/deploy-pages@v4
177+
158178
- name: Create GitHub status check
159179
if: github.event_name == 'pull_request'
160180
uses: actions/github-script@v8
161181
with:
162182
script: |
163-
const deployDir = process.env.DEPLOY_DIR;
183+
const deployDir = "${{ needs.prepare.outputs.deploy_dir }}";
164184
const deployUrl = `https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${deployDir}/`;
165185
const sha = context.payload.pull_request.head.sha;
166186

0 commit comments

Comments
 (0)