Skip to content

Leverage TextEncoderStream in html response #90

Leverage TextEncoderStream in html response

Leverage TextEncoderStream in html response #90

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
tags: [ v* ]
pull_request: {}
jobs:
check:
runs-on: ubuntu-latest
name: Check w/ ${{ matrix.deno-version }}
strategy:
matrix:
deno-version:
- v1.43
- canary
fail-fast: false # run each branch to completion
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Use Deno ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
# "file" cache: code from source control
# We're more selective here to prevent cross-branch contamination
# Disabled for now because https://github.com/denoland/deno/pull/12830
# - name: Cache file://
# uses: actions/cache@v4
# with:
# path: ~/.cache/deno/gen/file
# key: deno/${{ matrix.deno-version }}-file/v1-${{ github.ref }}-${{ github.sha }}
# restore-keys: deno/${{ matrix.deno-version }}-file/v1-${{ github.ref }}-
# "https" cache: code from the Internet
# External sources won't change much so we use less precise keys
- name: Cache https://
uses: actions/cache@v4
with:
path: ~/.cache/deno/deps/https
key: deno-https/v1-${{ hashFiles('**/deps.ts') }}
restore-keys: deno-https/v1-
- name: Check entrypoint
run: time deno check server.ts
- name: Run any tests
run: time deno test
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
needs: check
runs-on: ubuntu-latest
name: 'Push container image'
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Log into GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into Google Container Registry
uses: docker/login-action@v3
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCP_SA_KEY }}
- name: Pull latest image for cache
run: docker pull ghcr.io/${{ github.repository }}
- name: Build image
run: |
docker build . \
--cache-from ghcr.io/${{ github.repository }} \
--file Dockerfile \
--tag built-image
- name: Inspect image
run: docker images built-image
- name: Push image to GitHub Container Registry
id: push_ghcr
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
docker tag built-image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo "Pushed $IMAGE_ID:$VERSION"
echo "::set-output name=docker_image::$IMAGE_ID:$VERSION"
- name: Push image to Google Container Registry
id: push_gcr
run: |
IMAGE_ID=gcr.io/stardust-156404/deno-module-visualizer
VERSION=${{ github.sha }}
docker tag built-image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo "Pushed $IMAGE_ID:$VERSION"
echo "::set-output name=docker_image::$IMAGE_ID:$VERSION"
outputs:
ghcr_image: ${{ steps.push_ghcr.outputs.docker_image }}
gcr_image: ${{ steps.push_gcr.outputs.docker_image }}
deploy:
needs: push
runs-on: ubuntu-latest
name: 'Deploy to live site'
if: github.ref == 'refs/heads/main'
steps:
- name: Log in
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@v2
with:
project_id: stardust-156404
service: deno-module-visualizer
region: us-central1
image: ${{ needs.push.outputs.gcr_image }}