-
Notifications
You must be signed in to change notification settings - Fork 12
89 lines (77 loc) · 2.68 KB
/
build-target-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
# This workflow builds a specific regression test docker image. Using the
# input image short name from the workflow call, when the target image's
# version.txt is changed, the image is rebuilt and pushed to ghcr.io
name: Build and Publish a target Image
on:
workflow_call:
inputs:
image-short-name:
required: true
type: string
notebook-name:
required: true
type: string
shared-utils:
required: true
type: string
lfs:
required: true
type: string
env:
REGISTRY: ghcr.io
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout regression test repository
uses: actions/checkout@v4
with:
lfs: ${{inputs.lfs}}
- name: Did this image's version change?
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- ./test/${{inputs.image-short-name}}/version.txt
- name: Extract semantic version number
if: steps.changes.outputs.src == 'true'
working-directory: ./test/${{inputs.image-short-name}}
run: echo "semantic_version=$(cat version.txt)" >> $GITHUB_ENV
- name: Log-in to ghcr.io registry
if: steps.changes.outputs.src == 'true'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Add tags to the Docker image
if: steps.changes.outputs.src == 'true'
id: meta
uses: docker/metadata-action@v4
with:
images: "${{ env.REGISTRY }}/${{github.repository_owner}}/regression-tests-${{ inputs.image-short-name }}"
tags: |
type=semver,pattern={{version}},value=${{ env.semantic_version }}
- name: Set up Docker Buildx
if: steps.changes.outputs.src == 'true'
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:latest
- name: Build and Push Docker image
uses: docker/build-push-action@v3
if: steps.changes.outputs.src == 'true'
with:
build-args: |
notebook=${{inputs.notebook-name}}
sub_dir=${{inputs.image-short-name}}
shared_utils=${{inputs.shared-utils}}
file: ./test/Dockerfile
context: ./test
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Do nothing for this image
if: steps.changes.outputs.src == 'false'
run: echo "No changes required for this image ${{inputs.image-short-name}}"