-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathaction.yml
More file actions
99 lines (90 loc) · 3.52 KB
/
action.yml
File metadata and controls
99 lines (90 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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 }}'