-
Notifications
You must be signed in to change notification settings - Fork 14
146 lines (128 loc) · 4.5 KB
/
release-image.yml
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Create and publish a Docker image
# Cache setup: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
# Multi push: https://github.com/docker/build-push-action/blob/master/docs/advanced/push-multi-registries.md
on:
push:
branches: ['*']
jobs:
checks-update:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check update has been run
run: |
./update.sh
git diff --quiet
checks-hadolint:
runs-on: ubuntu-latest
permissions:
contents: read
container: hadolint/hadolint:latest-debian
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check hadolint
run: |
hadolint */Dockerfile
checks-shfmt:
runs-on: ubuntu-latest
permissions:
contents: read
container: mvdan/shfmt:latest-alpine
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check shfmt
run: |
shfmt -i 2 -ci -d update.sh
shfmt -i 2 -ci -d tools/adb-all
shfmt -i 2 -ci -d tools/license_accepter
shfmt -i 2 -ci -d tools-emulator/android-start-emulator
shfmt -i 2 -ci -d tools-emulator/android-wait-for-emulator
checks-shellcheck:
runs-on: ubuntu-latest
permissions:
contents: read
container: koalaman/shellcheck-alpine:latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check shellcheck
run: |
shellcheck update.sh
shellcheck tools/adb-all
shellcheck tools/license_accepter
shellcheck tools-emulator/android-start-emulator
shellcheck tools-emulator/android-wait-for-emulator
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
version: [ '32', '33' ]
variant: [ '', '-emulator', '-ndk', '-stf-client', '-jdk17', '-jdk11' ]
needs: [checks-hadolint, checks-shfmt, checks-shellcheck, checks-update]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check Exists
id: check-dir
run: |
if [ ! -d ${{ matrix.version }}${{ matrix.variant }} ]; then
echo "Directory ${{ matrix.version }}${{ matrix.variant }} does not exist"
echo "skipdir=true" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
if: steps.check-dir.outputs.skipdir != 'true'
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
if: steps.check-dir.outputs.skipdir != 'true' && github.ref == 'refs/heads/master'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Login to GAR
if: steps.check-dir.outputs.skipdir != 'true' && github.ref == 'refs/heads/master'
uses: docker/login-action@v2
with:
registry: europe-west1-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}
- name: Extract metadata (tags, labels) for Docker
id: meta
if: steps.check-dir.outputs.skipdir != 'true'
uses: docker/metadata-action@v4
with:
images: |
ekreative/android
europe-west1-docker.pkg.dev/ekreative-internal/ci/android
tags: |
type=raw,value=${{ matrix.version }}${{ matrix.variant }}
flavor: |
latest=${{ toJSON(matrix.version == '31' && matrix.variant == '' && github.ref == 'refs/heads/master') }}
- name: Cache Mode
id: cache-mode
if: steps.check-dir.outputs.skipdir != 'true'
run: |
if [ "$VARIANT" == '-emulator' ]; then
echo "::set-output name=mode::min"
else
echo "::set-output name=mode::max"
fi
env:
VARIANT: ${{ matrix.variant }}
- name: Build and push Docker image
if: steps.check-dir.outputs.skipdir != 'true'
uses: docker/build-push-action@v4
with:
context: ${{ matrix.version }}${{ matrix.variant }}
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=${{ steps.cache-mode.outputs.mode }}