-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (97 loc) · 3.29 KB
/
main-workflow-template.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
name: Template for each build job
on:
workflow_call:
inputs:
image:
description: Final release name
required: true
type: string
context:
description: Build context
required: true
type: string
base_image:
description: Name of the base image
required: true
type: string
java_versions:
description: Java versions (i.e. 11,19)
required: false
type: string
ada_versions:
description: Ada versions (i.e. 12.3)
required: false
type: string
jobs:
matrix_prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- id: set-matrix
run: |
matrix=$(python utils/generate-matrix.py --input_image ${{ inputs.base_image }} --output_image ${{ inputs.image }} \
--dh_orga liaslaboratory --images_prefix onyxia --ada_versions ${{ inputs.ada_versions }} --java_versions ${{ inputs.java_versions }} )
echo $matrix
echo "matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
docker:
runs-on: ubuntu-latest
needs: matrix_prep
strategy:
fail-fast: false
matrix:
${{fromJson(needs.matrix_prep.outputs.matrix)}}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Pass scripts to base image at build time
# Just to put the `scripts` folder at the root of the project
if: ${{ inputs.context == 'base' }}
run: cp -r scripts/ base/scripts/
- name: Make free space on GHA VM
uses: ./.github/actions/make-free-space
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and load to the Docker client
uses: docker/build-push-action@v6
with:
load: true
push: false
context: ${{ inputs.context }}
tags: ${{ matrix.output_image_tags }}
build-args: |
BASE_IMAGE=${{ matrix.base_image_tag }}
JAVA_VERSION=${{ matrix.java_version }}
secrets: |
"github_token=${{ secrets.GITHUB_TOKEN }}"
- name: Test image using Google's Container Structure Test
uses: ./.github/actions/container-structure-test
with:
image: ${{ matrix.output_image_main_tag }}
config: ./${{ inputs.context }}/tests.yaml
- name: Login to Docker Hub
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push to DockerHub
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v6
with:
push: true
context: ${{ inputs.context }}
tags: ${{ matrix.output_image_tags }}
build-args: |
BASE_IMAGE=${{ matrix.base_image_tag }}
JAVA_VERSION=${{ matrix.java_version }}
secrets: |
"github_token=${{ secrets.GITHUB_TOKEN }}"