Skip to content

Commit 2fbc840

Browse files
committed
ci: publish all builds to GH Pages
1 parent 19a7e7f commit 2fbc840

File tree

2 files changed

+54
-33
lines changed

2 files changed

+54
-33
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,47 @@ jobs:
8787
with:
8888
package_name: ${{ matrix.package }}
8989

90+
preview:
91+
runs-on: ubuntu-latest
92+
needs:
93+
- build
94+
- test
95+
if: ${{ needs.build.outputs.any-workspace == 'true' }}
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
package: ${{ fromJSON(needs.build.outputs.packages) }}
100+
exclude:
101+
- package: global
102+
- package: any-workspace
103+
name: Test ${{ matrix.package }}
104+
steps:
105+
- name: Determine GitHub Pages directory name
106+
id: branch_dir_name
107+
run: |
108+
if [ "$GITHUB_REF_NAME" == "develop" ]; then
109+
echo "result=."
110+
else
111+
echo "result=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}"
112+
fi | tee --append "$GITHUB_OUTPUT"
113+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
114+
with:
115+
name: build
116+
path: packages
117+
- name: Deploy ${{ matrix.package }} testing playground to GitHub Pages
118+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
119+
with:
120+
github_token: ${{ secrets.GITHUB_TOKEN }}
121+
publish_dir: ./packages/${{ matrix.package }}/playground
122+
destination_dir: "${{steps.branch_dir_name.outputs.result}}/${{ matrix.package }}"
123+
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
124+
90125
results:
91126
name: Results
92127
runs-on: ubuntu-latest
93-
needs: test
128+
needs:
129+
- test
130+
- preview
94131
if: ${{ always() }}
95132
steps:
96133
- run: |
@@ -109,3 +146,19 @@ jobs:
109146
exit 1
110147
;;
111148
esac
149+
- run: |
150+
case "${{ needs.preview.result }}" in
151+
success)
152+
echo "GitHub Pages previews published successfully."
153+
exit 0
154+
;;
155+
skipped)
156+
echo "Previews were unnecessary for these changes, so they were skipped."
157+
echo "If this is unexpected, check the path filters."
158+
exit 0
159+
;;
160+
*)
161+
echo "Publishing GitHub Pages previews failed."
162+
exit 1
163+
;;
164+
esac

.github/workflows/publish.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -145,35 +145,3 @@ jobs:
145145
run: |
146146
git tag -f "${{github.event.release.tag_name}}" HEAD
147147
git push -f origin "refs/tags/${{github.event.release.tag_name}}"
148-
149-
- name: Deploy scratch-svg-renderer to GitHub Pages
150-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
151-
with:
152-
github_token: ${{ secrets.GITHUB_TOKEN }}
153-
publish_dir: ./packages/scratch-svg-renderer/playground
154-
destination_dir: scratch-svg-renderer
155-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
156-
157-
- name: Deploy scratch-render to GitHub Pages
158-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
159-
with:
160-
github_token: ${{ secrets.GITHUB_TOKEN }}
161-
publish_dir: ./packages/scratch-render/playground
162-
destination_dir: scratch-render
163-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
164-
165-
- name: Deploy scratch-vm to GitHub Pages
166-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
167-
with:
168-
github_token: ${{ secrets.GITHUB_TOKEN }}
169-
publish_dir: ./packages/scratch-vm/playground
170-
destination_dir: scratch-vm
171-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
172-
173-
- name: Deploy scratch-gui to GitHub Pages
174-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
175-
with:
176-
github_token: ${{ secrets.GITHUB_TOKEN }}
177-
publish_dir: ./packages/scratch-gui/build
178-
destination_dir: scratch-gui
179-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"

0 commit comments

Comments
 (0)