@@ -19,23 +19,22 @@ jobs:
1919 any-workspace : ${{ steps.filter.outputs.any-workspace }}
2020 packages : ${{ steps.filter.outputs.changes }}
2121 steps :
22- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
23- - uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
22+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
23+ - uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
2424 with :
2525 cache : ' npm'
2626 node-version-file : ' .nvmrc'
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
5251
5352 - name : Store build artifacts
5453 if : ${{ steps.filter.outputs.any-workspace == 'true' }}
55- uses : actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
54+ uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5
5655 with :
5756 name : build
5857 path : |
@@ -73,25 +72,79 @@ jobs:
7372 - package : any-workspace
7473 name : Test ${{ matrix.package }}
7574 steps :
76- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
77- - uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
75+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
76+ - uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
7877 with :
7978 cache : ' npm'
8079 node-version-file : ' .nvmrc'
8180 - uses : ./.github/actions/install-dependencies
82- - uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
81+ - uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
8382 with :
8483 name : build
8584 path : packages
8685 - uses : ./.github/actions/test-package
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+ # - and
98+ # - it's not a Renovate branch (just to reduce noise)
99+ if : ${{
100+ (needs.build.outputs.any-workspace == 'true') &&
101+ (
102+ (!github.event.pull_request) ||
103+ (github.event.pull_request.head.repo.full_name == github.repository)
104+ ) &&
105+ (!startsWith((github.head_ref || github.ref_name), 'renovate/'))
106+ }}
107+ name : Publish preview playgrounds to GitHub Pages
108+ steps :
109+ - name : Determine GitHub Pages directory name
110+ id : branch_dir_name
111+ # even `develop` should be published to a subdirectory
112+ # that way each branch can be updated or cleaned up independently
113+ run : |
114+ echo "result=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" | tee --append "$GITHUB_OUTPUT"
115+ - uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
116+ with :
117+ name : build
118+ path : packages
119+ - name : Prepare playgrounds for GitHub Pages
120+ working-directory : ./packages
121+ run : |
122+ mkdir -p ../pages/
123+ for pkg in *; do
124+ if [ -d "${pkg}/playground" ]; then
125+ # using symlinks is quick and artifact generation will dereference them
126+ # if the GitHub Pages action stops dereferencing these links, we'll need to copy the files instead
127+ ln -s "../packages/${pkg}/playground" "../pages/${pkg}"
128+ fi
129+ done
130+
131+ # scratch-gui doesn't follow the pattern above
132+ ln -s "../packages/scratch-gui/build" "../pages/scratch-gui"
133+
134+ ls -l ../pages/
135+ - name : Deploy playgrounds to GitHub Pages
136+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
137+ with :
138+ github_token : ${{ secrets.GITHUB_TOKEN }}
139+ publish_dir : ./pages
140+ destination_dir : " ${{steps.branch_dir_name.outputs.result}}"
141+ full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
142+
90143 results :
91- name : Results
144+ name : Test Results
92145 runs-on : ubuntu-latest
93146 needs : test
94- if : ${{ always () }}
147+ if : ${{ !cancelled () }}
95148 steps :
96149 - run : |
97150 case "${{ needs.test.result }}" in
0 commit comments