@@ -27,15 +27,14 @@ jobs:
2727 - name : Debug info
2828 # https://docs.github.com/en/actions/reference/security/secure-use#use-an-intermediate-environment-variable
2929 env :
30- GH_HEAD_REF : ${{ github.head_ref }}
30+ # `env:` values are printed to the log even without using them in `run:`
31+ GH_CONTEXT : ${{ toJson(github) }}
3132 run : |
3233 cat <<EOF
33- Scratch environment : ${{ vars.SCRATCH_ENV || '<none>' }}
34+ Working directory : $(pwd)
3435 Node version: $(node --version)
3536 NPM version: $(npm --version)
36- GitHub ref: ${{ github.ref }}
37- GitHub head ref: ${GH_HEAD_REF}
38- Working directory: $(pwd)
37+ Scratch environment: ${{ vars.SCRATCH_ENV || '<none>' }}
3938 EOF
4039
4140 - uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
8786 with :
8887 package_name : ${{ matrix.package }}
8988
89+ preview :
90+ runs-on : ubuntu-latest
91+ needs : build
92+ # We don't want to give forks free reign to publish to our GitHub Pages, so run this job only if both:
93+ # - any workspace changed (otherwise there's no work to do)
94+ # - and either
95+ # - this is not a PR (so it's some other event that happened in our fork, like a push or merge group)
96+ # - or it's a PR from our fork (not some other fork)
97+ if : ${{
98+ (needs.build.outputs.any-workspace == 'true') &&
99+ (
100+ (!github.event.pull_request) ||
101+ (github.event.pull_request.head.repo.full_name == github.repository)
102+ )
103+ }}
104+ name : Publish preview playgrounds to GitHub Pages
105+ steps :
106+ - name : Determine GitHub Pages directory name
107+ id : branch_dir_name
108+ run : |
109+ if [ "$GITHUB_REF_NAME" == "develop" ]; then
110+ echo "result=."
111+ else
112+ echo "result=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}"
113+ fi | tee --append "$GITHUB_OUTPUT"
114+ - uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
115+ with :
116+ name : build
117+ path : packages
118+ - name : Prepare playgrounds for GitHub Pages
119+ working-directory : ./packages
120+ run : |
121+ mkdir -p ../pages/
122+ for pkg in *; do
123+ if [ -d "${pkg}/playground" ]; then
124+ # using symlinks is quick and artifact generation will dereference them
125+ # if the GitHub Pages action stops dereferencing these links, we'll need to copy the files instead
126+ ln -s "../packages/${pkg}/playground" "../pages/${pkg}"
127+ fi
128+ done
129+
130+ # scratch-gui doesn't follow the pattern above
131+ ln -s "../packages/scratch-gui/build" "../pages/scratch-gui"
132+
133+ ls -l ../pages/
134+ - name : Deploy playgrounds to GitHub Pages
135+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
136+ with :
137+ github_token : ${{ secrets.GITHUB_TOKEN }}
138+ publish_dir : ./pages
139+ destination_dir : " ${{steps.branch_dir_name.outputs.result}}"
140+ full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
141+
90142 results :
91- name : Results
143+ name : Test Results
92144 runs-on : ubuntu-latest
93145 needs : test
94146 if : ${{ !cancelled() }}
0 commit comments