|
1 | 1 | name: chromium-headless-image |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
4 | 7 | workflow_call: |
5 | 8 |
|
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
6 | 13 | jobs: |
7 | 14 | docker: |
8 | | - runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - arch: amd64 |
| 20 | + runner: ubuntu-latest |
| 21 | + - arch: arm64 |
| 22 | + runner: ubuntu-24.04-arm64 |
| 23 | + runs-on: ${{ matrix.runner }} |
9 | 24 | permissions: |
10 | 25 | contents: read |
| 26 | + env: |
| 27 | + UKC_TOKEN: dummy |
| 28 | + UKC_METRO: ci |
| 29 | + NAME: ci-chromium-headless |
| 30 | + DETACH: "true" |
| 31 | + SERVICE_EXCEPTIONS: pulseaudio |
11 | 32 | steps: |
12 | 33 | - name: Checkout |
13 | 34 | uses: actions/checkout@v4 |
14 | 35 |
|
15 | | - - name: Compute short SHA |
16 | | - id: vars |
| 36 | + - name: Build image |
17 | 37 | shell: bash |
18 | | - run: echo "short_sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" |
| 38 | + run: | |
| 39 | + bash images/chromium-headless/build-docker.sh |
19 | 40 |
|
20 | | - - name: Login to Docker Hub |
21 | | - uses: docker/login-action@v3 |
22 | | - with: |
23 | | - username: ${{ vars.DOCKERHUB_USERNAME }} |
24 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 41 | + - name: Run container |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + bash images/chromium-headless/run-docker.sh |
25 | 45 |
|
26 | | - - name: Set up Docker Buildx |
27 | | - uses: docker/setup-buildx-action@v3 |
| 46 | + - name: Wait for supervisor services (allow pulseaudio non-RUNNING) |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + trap "docker stop ci-chromium-headless >/dev/null 2>&1 || true" EXIT |
| 50 | + attempts=30 |
| 51 | + sleep_seconds=1 |
| 52 | + for i in $(seq 1 "$attempts"); do |
| 53 | + out=$(docker exec ci-chromium-headless supervisorctl status || true) |
| 54 | + echo "$out" |
| 55 | + total=$(echo "$out" | grep -v '^$' | wc -l | tr -d ' ') |
| 56 | + exceptions="${SERVICE_EXCEPTIONS:-}" |
| 57 | + pattern=$(printf '%s' "$exceptions" | tr ', ' '\n' | sed '/^$/d' | paste -sd '|' -) |
| 58 | + ok=$(echo "$out" | awk -v pat="$pattern" 'BEGIN{IGNORECASE=1} { if (pat != "" && $0 ~ pat) print; else if ($0 ~ /RUNNING/) print }' | wc -l | tr -d ' ') |
| 59 | + if [ "$total" -gt 0 ] && [ "$ok" -eq "$total" ]; then |
| 60 | + echo "All required services are RUNNING" |
| 61 | + exit 0 |
| 62 | + fi |
| 63 | + sleep "$sleep_seconds" |
| 64 | + done |
| 65 | + echo "Supervisor services not ready in time" |
| 66 | + docker logs --tail=200 ci-chromium-headless || true |
| 67 | + exit 1 |
28 | 68 |
|
29 | | - - name: Build and push |
30 | | - uses: docker/build-push-action@v6 |
31 | | - with: |
32 | | - context: . |
33 | | - file: images/chromium-headless/image/Dockerfile |
34 | | - push: true |
35 | | - tags: onkernel/chromium-headless:${{ steps.vars.outputs.short_sha }} |
36 | | - cache-from: type=gha |
37 | | - cache-to: type=gha,mode=max |
|
0 commit comments