Skip to content

Playground Preview Upload #6

Playground Preview Upload

Playground Preview Upload #6

name: Playground Preview Upload
on:
workflow_run:
workflows: [CI]
types: [completed]
jobs:
upload:
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.pull_requests[0].base.ref == 'master' }}
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
pull-requests: write
env:
PLAYGROUND_PREVIEW_ID: pr-${{ github.event.workflow_run.pull_requests[0].number }}
steps:
- name: Download preview bundle artifact
uses: actions/download-artifact@v8
with:
name: dev-playground-pr-${{ github.event.workflow_run.pull_requests[0].number }}-bundle
path: dev-playground-preview-bundle
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Rclone
uses: cometkim/rclone-actions/setup-rclone@main
- name: Configure Rclone remote
uses: cometkim/rclone-actions/configure-remote/s3-provider@main
with:
name: rescript
provider: Cloudflare
endpoint: https://${{ vars.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
access-key-id: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
acl: private
- name: Upload preview bundle
run: |
rclone sync \
--stats 5 \
--checkers 5000 \
--transfers 8 \
--buffer-size 128M \
--s3-no-check-bucket \
--s3-chunk-size 128M \
--s3-upload-concurrency 8 \
--fast-list \
"dev-playground-preview-bundle" \
"rescript:cdn-assets/dev-playground-bundles/${PLAYGROUND_PREVIEW_ID}/bundle"
- name: Comment playground preview URL
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
comment-tag: dev-playground-preview
message: |
Developer playground preview: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/dev-playground/?version=pr-${{ github.event.workflow_run.pull_requests[0].number }}