-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (81 loc) · 2.96 KB
/
Copy pathdeploy.yml
File metadata and controls
92 lines (81 loc) · 2.96 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
name: Deploy container
on:
push:
branches:
- main
jobs:
matrix:
name: Generate build matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- uses: actions/checkout@v7
- name: Generate matrix from matrix.json
id: generate
run: |
DEFAULT_JDK=$(jq -r '.default_jdk' matrix.json)
MATRIX=$(jq -c --arg default "$DEFAULT_JDK" '{
"include": [.java_versions[] | {
"java_version": .,
"is_default_jdk": (. == $default)
}]
}' matrix.json)
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
deploy:
name: Build JDK ${{ matrix.java_version }}
needs: matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v7
- name: Extract versions from Dockerfile
id: versions
run: |
set -euo pipefail
RUNNER_TAG=$(grep -m1 '^ARG VERSION=' Dockerfile | cut -d= -f2)
RUNNER_VERSION=$(echo "$RUNNER_TAG" | cut -d- -f1)
COMPILE_SDK=$(grep -m1 '^ARG COMPILE_SDK=' Dockerfile | cut -d= -f2)
if [ -z "$RUNNER_TAG" ] || [ -z "$RUNNER_VERSION" ] || [ -z "$COMPILE_SDK" ]; then
echo "::error::Failed to extract versions from Dockerfile"
exit 1
fi
echo "runner_tag=${RUNNER_TAG}" >> $GITHUB_OUTPUT
echo "runner_version=${RUNNER_VERSION}" >> $GITHUB_OUTPUT
echo "compile_sdk=${COMPILE_SDK}" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/github-runner-android
ghcr.io/${{ github.repository_owner }}/github-runner-android
tags: |
type=raw,value=jdk${{ matrix.java_version }}
type=raw,value=${{ steps.versions.outputs.runner_version }}-jdk${{ matrix.java_version }}-sdk${{ steps.versions.outputs.compile_sdk }}
type=raw,value=latest,enable=${{ matrix.is_default_jdk }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
push: true
build-args: |
VERSION=${{ steps.versions.outputs.runner_tag }}
JAVA_VERSION=${{ matrix.java_version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}