Files
2026-07-13 13:05:14 +08:00

199 lines
7.6 KiB
YAML

name: Reusable Upload Web
on:
workflow_call:
inputs:
CONCURRENCY:
required: true
type: string
ADHOC_NAME:
type: string
required: false
default: ""
MARK_TAGGED_VERSION:
required: false
type: boolean
default: false
RELEASE_VERSION:
required: false
type: string
default: "prerelease"
PR_NUMBER:
required: false
type: string
default: ""
NIGHTLY:
required: false
type: boolean
default: false
concurrency:
group: ${{ inputs.CONCURRENCY }}-upload-web
cancel-in-progress: true
defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}
permissions:
contents: "write"
id-token: "write"
pull-requests: "write"
jobs:
upload-web:
name: Upload web build to google cloud (wasm32 + wasm-bindgen)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || '' }}
- name: Download Web Viewer
uses: actions/download-artifact@v4
with:
name: web_viewer
path: "crates/viewer/re_web_viewer_server/web_viewer"
# Upload the wasm, html etc to a Google cloud bucket:
- id: "auth"
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
with:
version: ">= 363.0.0"
- name: Get sha
id: get-sha
run: |
full_commit="${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha }}"
echo "sha=$(echo $full_commit | cut -c1-7)" >> "$GITHUB_OUTPUT"
- name: "Upload web-viewer (commit)"
if: ${{ !inputs.NIGHTLY }}
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "crates/viewer/re_web_viewer_server/web_viewer"
destination: "rerun-web-viewer/commit/${{ steps.get-sha.outputs.sha }}"
parent: false
process_gcloudignore: false
- name: "Upload web-viewer (tagged)"
if: inputs.MARK_TAGGED_VERSION
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "crates/viewer/re_web_viewer_server/web_viewer"
destination: "rerun-web-viewer/version/${{inputs.RELEASE_VERSION}}"
parent: false
process_gcloudignore: false
- name: "Upload web-viewer (adhoc)"
if: ${{ inputs.ADHOC_NAME != '' }}
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "crates/viewer/re_web_viewer_server/web_viewer"
destination: "rerun-web-viewer/adhoc/${{inputs.ADHOC_NAME}}"
parent: false
process_gcloudignore: false
- name: "Upload web-viewer (prerelease)"
if: github.ref == 'refs/heads/main'
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "crates/viewer/re_web_viewer_server/web_viewer"
destination: "rerun-web-viewer/prerelease"
parent: false
process_gcloudignore: false
headers: |-
cache-control: no-cache, max-age=0
- name: "Upload web-viewer (main)"
if: github.ref == 'refs/heads/main'
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "crates/viewer/re_web_viewer_server/web_viewer"
destination: "rerun-web-viewer/version/main"
parent: false
process_gcloudignore: false
headers: |-
cache-control: no-cache, max-age=0
- name: "Upload web-viewer (pr)"
if: ${{ inputs.PR_NUMBER != '' }}
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "crates/viewer/re_web_viewer_server/web_viewer"
destination: "rerun-web-viewer/pr/${{ inputs.PR_NUMBER }}"
parent: false
process_gcloudignore: false
headers: |-
cache-control: no-cache, max-age=0
- name: "Upload web-viewer (nightly)"
if: ${{ inputs.NIGHTLY }}
uses: google-github-actions/upload-cloud-storage@v3
with:
path: "crates/viewer/re_web_viewer_server/web_viewer"
destination: "rerun-web-viewer/version/nightly"
parent: false
process_gcloudignore: false
headers: |-
cache-control: no-cache, max-age=0
# Upload extensionless HTML aliases (signed-in, signed-out) to the
# bucket root with the correct Content-Type. The OAuth redirect uses the
# origin (app.rerun.io/signed-in), not a versioned path.
- name: "Upload HTML aliases to bucket root"
run: |
cd crates/viewer/re_web_viewer_server/web_viewer
for f in *.html; do
name="${f%.html}"
if [ "$name" != "index" ] && [ "$name" != "index_bundled" ]; then
gcloud storage cp --content-type="text/html" "$f" "gs://rerun-web-viewer/${name}"
fi
done
- name: Status comment
if: success() && github.event_name == 'pull_request'
# https://github.com/mshick/add-pr-comment
uses: mshick/add-pr-comment@v3.9.1
# GitHub API is very unreliable. We don't want to fail the entire workflow just because we couldn't post a comment.
continue-on-error: true
with:
message-id: "web-viewer-build-status"
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
Web viewer built successfully.
| Result | Commit | Link | Manifest |
| ------ | ------- | ---- | -------- |
| ✅ | ${{ steps.get-sha.outputs.sha }} | https://rerun.io/viewer/pr/${{ github.event.pull_request.number }} | [`+nightly`](https://rerun.io/viewer/pr/${{ github.event.pull_request.number }}?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) [`+main`](https://rerun.io/viewer/pr/${{ github.event.pull_request.number }}?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) |
View image diff on [kitdiff](https://rerun-io.github.io/kitdiff/?url=${{github.event.pull_request.html_url}}).
<sup>Note: This comment is updated whenever you push a commit.</sup>
- name: Status comment
if: failure() && github.event_name == 'pull_request'
# https://github.com/mshick/add-pr-comment
uses: mshick/add-pr-comment@v3.9.1
# GitHub API is very unreliable. We don't want to fail the entire workflow just because we couldn't post a comment.
continue-on-error: true
with:
message-id: "web-viewer-build-status"
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
Web viewer failed to build.
| Result | Commit | Link | Manifest |
| ------ | ------- | ----- |
| ❌ | ${{ steps.get-sha.outputs.sha }} | https://rerun.io/viewer/pr/${{ github.event.pull_request.number }} | [`+nightly`](https://rerun.io/viewer/pr/${{ github.event.pull_request.number }}?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) [`+main`](https://rerun.io/viewer/pr/${{ github.event.pull_request.number }}?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) |
View image diff on [kitdiff](https://rerun-io.github.io/kitdiff/?url=${{github.event.pull_request.html_url}}).
<sup>Note: This comment is updated whenever you push a commit.</sup>