Repository navigation
116 lines (100 loc) · 3.5 KB
/
Copy pathbuild.yml
File metadata and controls
116 lines (100 loc) · 3.5 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Build
on:
push:
jobs:
docker:
name: Docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
tag:
- basic
- docworker
- docworker-lambda
env:
PUBLIC_IMAGE_PREFIX: 'ghcr.io/ds-wizard'
IMAGE_BASE_NAME: 'python-base'
DOCKER_META_CONTEXT: '.'
DOCKER_META_FILE: './${{ matrix.tag }}/Dockerfile'
DOCKER_META_PLATFORMS: 'linux/amd64,linux/arm64'
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v4
- name: Set short SHA
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
# TEST DOCKER IMAGE BUILD
- name: Docker meta [test]
id: meta-test
uses: docker/metadata-action@v6
with:
images: |
${{ env.PUBLIC_IMAGE_PREFIX }}/${{ env.IMAGE_BASE_NAME }}
tags: |
type=raw,value=${{ matrix.tag }}
type=raw,value=${{ matrix.tag }}-${{ steps.vars.outputs.sha_short }}
- name: Docker build+push [test]
uses: docker/build-push-action@v7
with:
context: ${{ env.DOCKER_META_CONTEXT }}
file: ${{ env.DOCKER_META_FILE }}
platforms: ${{ env.DOCKER_META_PLATFORMS }}
push: false
tags: ${{ steps.meta-test.outputs.tags }}
labels: ${{ steps.meta-test.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# SMOKE TEST (amd64 only, loaded into local Docker)
- name: Docker build [smoke test]
uses: docker/build-push-action@v7
with:
context: ${{ env.DOCKER_META_CONTEXT }}
file: ${{ env.DOCKER_META_FILE }}
platforms: linux/amd64
load: true
tags: python-base-test:${{ matrix.tag }}
cache-from: type=gha
- name: Smoke test
run: ./tests/run.sh ${{ matrix.tag }} python-base-test:${{ matrix.tag }}
# PUBLIC: GITHUB CONTAINER REGISTRY
- name: Docker login [public]
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta [public]
id: meta-public
if: github.event_name != 'pull_request'
uses: docker/metadata-action@v6
with:
images: |
${{ env.PUBLIC_IMAGE_PREFIX }}/${{ env.IMAGE_BASE_NAME }}
tags: |
type=raw,value=${{ matrix.tag }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=${{ matrix.tag }}-${{ steps.vars.outputs.sha_short }}
type=semver,pattern={{version}},suffix=-${{ matrix.tag }}
type=semver,pattern={{major}}.{{minor}},suffix=-${{ matrix.tag }}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }},suffix=-${{ matrix.tag }}
- name: Docker build+push [public]
uses: docker/build-push-action@v7
if: github.event_name != 'pull_request' && steps.meta-public.outputs.tags != ''
with:
context: ${{ env.DOCKER_META_CONTEXT }}
file: ${{ env.DOCKER_META_FILE }}
platforms: ${{ env.DOCKER_META_PLATFORMS }}
push: true
tags: ${{ steps.meta-public.outputs.tags }}
labels: ${{ steps.meta-public.outputs.labels }}