Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions .github/actions/docker-publish/action.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/actions/docker-skiko-publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 'Docker Skiko Publish'
description: 'Build and optionally publish a Docker image to ghcr.io for skiko'

inputs:
image_name:
description: 'Image name (e.g., linux-compat)'
required: true
platforms:
description: 'Target platforms (e.g., linux/amd64 or linux/amd64,linux/arm64). If not specified, uses runner architecture.'
required: false
tag:
description: 'Image tag (e.g., latest)'
required: true
load:
description: 'Whether to load the image into the local Docker daemon'
required: false
default: 'false'
should_publish:
description: 'Whether to push the image to the registry'
required: true
github_token:
description: 'GitHub token for authentication (required only if should_publish is true)'
required: false

runs:
using: 'composite'
steps:
- name: 'Set Variables'
id: vars
shell: bash
run: |
echo "image_namespace=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT

# Normalize tag: replace invalid docker tag characters
TAG="${{ inputs.tag }}"
TAG="${TAG//\//-}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT

- name: 'Set up Docker Buildx'
uses: docker/setup-buildx-action@v3

- name: 'Log into registry'
if: inputs.should_publish == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.github_token }}

- name: 'Extract metadata'
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.vars.outputs.image_namespace }}/${{ inputs.image_name }}
tags: |
type=raw,value=${{ steps.vars.outputs.tag }}

- name: 'Build and push'
uses: docker/build-push-action@v5
with:
context: ./skiko/docker/${{ inputs.image_name }}
platforms: ${{ inputs.platforms }}
push: ${{ inputs.should_publish == 'true' }}
load: ${{ inputs.load == 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
99 changes: 99 additions & 0 deletions .github/actions/docker-skiko-run/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: 'Docker Skiko Run'
description: 'Build Docker image locally if needed and run commands inside it'

inputs:
image_name:
description: 'Image name (e.g., linux-compat)'
required: true
command:
description: 'Command to run inside the container'
required: true
working_directory:
description: 'Working directory relative to project root (e.g., samples/SkiaAndroidSample)'
required: false
default: '.'
virtual-display:
description: 'Enable virtual display for UI testing (enables e2e UI interaction tests with real windows)'
required: false
default: 'false'
base_ref:
description: 'Base ref/sha for change detection (defaults to auto-detect)'
required: false
default: ''

runs:
using: 'composite'
steps:
- name: 'Detect Docker changes'
id: filter
uses: dorny/paths-filter@v3
with:
base: ${{ inputs.base_ref || github.event.pull_request.base.sha || github.event.before || 'master' }}
filters: |
docker_changed:
- '.github/actions/docker-skiko-publish/**'
- '.github/workflows/docker-publish.yml'
- 'skiko/docker/${{ inputs.image_name }}/**'

- name: 'Set Variables'
id: vars
shell: bash
run: |
IMAGE_NAMESPACE="${GITHUB_REPOSITORY,,}"
echo "image_namespace=${IMAGE_NAMESPACE}" >> $GITHUB_OUTPUT

# Determine which tag to use
# github.base_ref is set for PRs regardless of event type (pull_request or workflow_call)
if [[ -n "${{ github.base_ref }}" && "${{ steps.filter.outputs.docker_changed }}" != "true" ]]; then
# For PRs without docker changes, use base branch tag (pre-built image)
TAG="${{ github.base_ref }}"
else
# For PRs with docker changes or non-PRs, use current branch tag
TAG="${GITHUB_REF_NAME}"
fi
TAG="${TAG//\//-}"

# Try to pull image from GHCR
# This checks both if the image exists in the registry and loads it into the local daemon
if docker pull "ghcr.io/${IMAGE_NAMESPACE}/${{ inputs.image_name }}:${TAG}" >/dev/null 2>&1; then
IMAGE_EXISTS="true"
else
IMAGE_EXISTS="false"
fi

echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "image_exists=${IMAGE_EXISTS}" >> $GITHUB_OUTPUT

- name: 'Build Docker image locally (if needed)'
if: steps.filter.outputs.docker_changed == 'true' || steps.vars.outputs.image_exists == 'false'
uses: ./.github/actions/docker-skiko-publish
with:
image_name: ${{ inputs.image_name }}
tag: ${{ steps.vars.outputs.tag }}
load: true
should_publish: false

- name: 'Prepare command'
id: cmd
shell: bash
run: |
CMD="${{ inputs.command }}"
if [[ "${{ inputs.virtual-display }}" == "true" ]]; then
CMD="Xvfb :1 -screen 0 1920x1080x24 -extension RANDR +extension GLX & export DISPLAY=:1.0 && ${CMD}"
fi
{
echo "command<<EOF"
echo "${CMD}"
echo "EOF"
} >> $GITHUB_OUTPUT

- name: 'Run command in container'
shell: bash
run: |
docker run --rm \
-v "${{ github.workspace }}":/workspace \
-v "${HOME}/.gradle":/gradle-cache \
-e GRADLE_USER_HOME=/gradle-cache \
-w /workspace/${{ inputs.working_directory }} \
"ghcr.io/${{ steps.vars.outputs.image_namespace }}/${{ inputs.image_name }}:${{ steps.vars.outputs.tag }}" \
bash -c '${{ steps.cmd.outputs.command }}'
12 changes: 12 additions & 0 deletions .github/actions/setup-prerequisites/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
name: 'Setup Prerequisites'
description: 'Shared steps to prepare build environment'

runs:
using: "composite"
steps:
- name: Free up space on GitHub runner
if: runner.os == 'Linux'
shell: bash
run: |
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
df -h

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
Expand Down
Loading
Loading