fix: use SABR for embedded YouTube playback #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker | |
| on: | |
| push: | |
| branches: ["dev", "main"] | |
| workflow_dispatch: | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| REGISTRY: ghcr.io | |
| concurrency: | |
| group: frontend-docker-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| verify: | |
| uses: ./.github/workflows/ci.yml | |
| prepare: | |
| needs: verify | |
| runs-on: [self-hosted, Linux, X64, arko, typetype] | |
| permissions: | |
| contents: read | |
| outputs: | |
| build-time: ${{ steps.info.outputs.build-time }} | |
| channel: ${{ steps.info.outputs.channel }} | |
| image: ${{ steps.info.outputs.image }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| metadata-json: ${{ steps.meta.outputs.json }} | |
| version: ${{ steps.info.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - uses: oven-sh/setup-bun@v2.2.0 | |
| with: | |
| bun-version: "1.3.14" | |
| - name: Resolve build metadata | |
| id: info | |
| run: | | |
| base_version="$(bun -e 'console.log(require("./package.json").version)')" | |
| if [[ "$GITHUB_REF_NAME" == "main" ]]; then | |
| channel="stable" | |
| image="${REGISTRY}/typetype-video/typetype" | |
| version="$base_version" | |
| else | |
| channel="beta" | |
| image="${REGISTRY}/typetype-video/typetype-beta" | |
| version="$base_version-beta.$GITHUB_RUN_NUMBER" | |
| fi | |
| { | |
| echo "build-time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
| echo "channel=$channel" | |
| echo "image=$image" | |
| echo "version=$version" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Extract image metadata | |
| id: meta | |
| uses: docker/metadata-action@v6.0.0 | |
| with: | |
| images: ${{ steps.info.outputs.image }} | |
| tags: | | |
| type=sha,prefix=sha-,format=short | |
| type=raw,value=${{ steps.info.outputs.version }} | |
| type=raw,value=latest,enable=${{ github.ref_name == 'main' }} | |
| type=raw,value=beta,enable=${{ github.ref_name == 'dev' }} | |
| type=raw,value=latest,enable=${{ github.ref_name == 'dev' }} | |
| build-platform: | |
| needs: prepare | |
| runs-on: [self-hosted, Linux, X64, arko, typetype] | |
| timeout-minutes: 20 | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| arch: amd64 | |
| - platform: linux/arm64 | |
| arch: arm64 | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - name: Isolate Docker credentials | |
| run: echo "DOCKER_CONFIG=$RUNNER_TEMP/docker-config" >> "$GITHUB_ENV" | |
| - uses: docker/login-action@v4.1.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/setup-qemu-action@v4.1.0 | |
| if: matrix.arch == 'arm64' | |
| with: | |
| platforms: arm64 | |
| cache-image: false | |
| - uses: docker/setup-buildx-action@v4.0.0 | |
| - name: Build and push platform image | |
| id: build | |
| uses: docker/build-push-action@v7.1.0 | |
| with: | |
| context: . | |
| build-args: | | |
| BUILD_VERSION=${{ needs.prepare.outputs.version }} | |
| BUILD_REVISION=${{ github.sha }} | |
| BUILD_TIME=${{ needs.prepare.outputs.build-time }} | |
| platforms: ${{ matrix.platform }} | |
| pull: true | |
| labels: ${{ needs.prepare.outputs.labels }} | |
| outputs: type=image,name=${{ needs.prepare.outputs.image }},push-by-digest=true,name-canonical=true,push=true | |
| provenance: false | |
| cache-from: type=gha,scope=frontend-${{ matrix.arch }} | |
| cache-to: type=gha,mode=max,scope=frontend-${{ matrix.arch }} | |
| - name: Export digest | |
| env: | |
| DIGEST: ${{ steps.build.outputs.digest }} | |
| run: | | |
| digest_dir="$RUNNER_TEMP/frontend-digests" | |
| rm -rf "$digest_dir" | |
| mkdir -p "$digest_dir" | |
| touch "$digest_dir/${DIGEST#sha256:}" | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: frontend-digest-${{ matrix.arch }}-${{ github.run_id }}-${{ github.run_attempt }} | |
| path: ${{ runner.temp }}/frontend-digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| publish: | |
| needs: [prepare, build-platform] | |
| runs-on: [self-hosted, Linux, X64, arko, typetype] | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| packages: write | |
| outputs: | |
| digest: ${{ steps.manifest.outputs.digest }} | |
| steps: | |
| - name: Isolate Docker credentials | |
| run: echo "DOCKER_CONFIG=$RUNNER_TEMP/docker-config" >> "$GITHUB_ENV" | |
| - name: Prepare digest directory | |
| run: rm -rf "$RUNNER_TEMP/frontend-digests" | |
| - uses: actions/download-artifact@v8.0.1 | |
| with: | |
| path: ${{ runner.temp }}/frontend-digests | |
| pattern: frontend-digest-*-${{ github.run_id }}-${{ github.run_attempt }} | |
| merge-multiple: true | |
| - uses: docker/login-action@v4.1.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/setup-buildx-action@v4.0.0 | |
| - name: Publish manifest list | |
| id: manifest | |
| env: | |
| DIGEST_DIR: ${{ runner.temp }}/frontend-digests | |
| IMAGE: ${{ needs.prepare.outputs.image }} | |
| METADATA_JSON: ${{ needs.prepare.outputs.metadata-json }} | |
| run: | | |
| mapfile -t digests < <(find "$DIGEST_DIR" -maxdepth 1 -type f -printf '%f\n' | sort) | |
| if [[ "${#digests[@]}" -ne 2 ]]; then | |
| echo "Expected two platform digests, found ${#digests[@]}" | |
| exit 1 | |
| fi | |
| mapfile -t tags < <(jq -r '.tags[]' <<< "$METADATA_JSON") | |
| tag_args=() | |
| for tag in "${tags[@]}"; do tag_args+=(--tag "$tag"); done | |
| source_args=() | |
| for digest in "${digests[@]}"; do source_args+=("$IMAGE@sha256:$digest"); done | |
| docker buildx imagetools create "${tag_args[@]}" "${source_args[@]}" | |
| manifest_json="$(docker buildx imagetools inspect "${tags[0]}" --format '{{json .Manifest}}')" | |
| digest="$(jq -r '.digest' <<< "$manifest_json")" | |
| if [[ "$digest" != sha256:* ]]; then | |
| echo "Published manifest has no valid digest" | |
| exit 1 | |
| fi | |
| echo "digest=$digest" >> "$GITHUB_OUTPUT" | |
| notify-orchestrator: | |
| needs: [prepare, publish] | |
| runs-on: [self-hosted, Linux, X64, arko, typetype] | |
| permissions: | |
| contents: read | |
| env: | |
| GH_TOKEN: ${{ secrets.TYPETYPE_ORCHESTRATOR_TOKEN }} | |
| steps: | |
| - name: Send image digest | |
| env: | |
| CHANNEL: ${{ needs.prepare.outputs.channel }} | |
| DIGEST: ${{ needs.publish.outputs.digest }} | |
| IMAGE: ${{ needs.prepare.outputs.image }} | |
| VERSION: ${{ needs.prepare.outputs.version }} | |
| run: | | |
| jq -n \ | |
| --arg channel "$CHANNEL" \ | |
| --arg component "frontend" \ | |
| --arg digest "$DIGEST" \ | |
| --arg image "$IMAGE" \ | |
| --arg revision "$GITHUB_SHA" \ | |
| --arg version "$VERSION" \ | |
| '{event_type:"component-image",client_payload:{channel:$channel,component:$component,digest:$digest,image:$image,revision:$revision,version:$version}}' \ | |
| | gh api --method POST repos/TypeType-Video/TypeType/dispatches --input - |