Skip to content

ci: lower test cases number #11

ci: lower test cases number

ci: lower test cases number #11

Workflow file for this run

name: Docker
on:
push:
tags:
- 'v*.*.*'
- 'v*-*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
RUN_TESTS_IMAGE: node:22-alpine
jobs:
build-cli:
strategy:
fail-fast: false
matrix:
include:
- docker-platform: linux/amd64
rust-target: x86_64-unknown-linux-musl
- docker-platform: linux/arm64
rust-target: aarch64-unknown-linux-musl
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
env:
CLI_CACHE_SCOPE: cli-${{ matrix.rust-target }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.0.0
- name: Build tests image (with GHA cache)
uses: docker/build-push-action@v7.1.0
with:
context: .
file: docker/cli.Dockerfile
target: cli-tester
platforms: ${{ matrix.docker-platform }}
build-args: |
RUST_TARGET=${{ matrix.rust-target }}
tags: cli-tester:latest
load: true
push: false
cache-from: type=gha,scope=${{ env.CLI_CACHE_SCOPE }}
cache-to: type=gha,mode=max,scope=${{ env.CLI_CACHE_SCOPE }}
- name: Run tests
run: docker run --rm --platform ${{ matrix.docker-platform }} cli-tester:latest
- name: Export CLI binary (reuse cache)
uses: docker/build-push-action@v7.1.0
with:
context: .
file: docker/cli.Dockerfile
target: cli-binary
platforms: ${{ matrix.docker-platform }}
build-args: |
RUST_TARGET=${{ matrix.rust-target }}
outputs: type=local,dest=./cli
push: false
cache-from: type=gha,scope=${{ env.CLI_CACHE_SCOPE }}
cache-to: type=gha,mode=max,scope=${{ env.CLI_CACHE_SCOPE }}
- name: Upload CLI binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cli/unipress
asset_name: unipress-${{ matrix.rust-target }}
tag: ${{ github.ref }}
overwrite: true
body: "Unipress CLI binary (${{ matrix.rust-target }})"
build-wasm-image:
needs: build-cli
runs-on: ubuntu-latest
outputs:
image_ref: ${{ steps.image-ref.outputs.image_ref }}
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install cosign
uses: sigstore/cosign-installer@v4.1.1
with:
cosign-release: 'v2.2.4'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.0.0
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v4.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v7.1.0
with:
context: .
file: docker/wasm.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Export image ref for Pages deploy
id: image-ref
run: |
echo "image_ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }}" >> "$GITHUB_OUTPUT"
- name: Sign the published Docker image
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
deploy-pages:
needs: build-wasm-image
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
packages: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v4.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull image and extract nginx document root
run: |
set -eux
ref='${{ needs.build-wasm-image.outputs.image_ref }}'
docker pull "$ref"
cid="$(docker create "$ref")"
docker cp "$cid":/usr/share/nginx/html ./static
docker rm "$cid"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./static
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5