-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
61 lines (56 loc) · 2.15 KB
/
action.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
name: 'Build Container'
description: 'Build container and push it to NAIL CR'
inputs:
image-name:
description: 'Image to build'
required: true
working-dir:
description: 'Working directory. Defaults to `image-name/`'
required: false
dockerfile:
description: 'Path to dockerfile relative to working directory'
required: false
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v3
with:
images: cr.nail.science/ml-containers/${{ inputs.image-name }}
sep-tags: ','
tags: |
type=semver,prefix=v,pattern={{major}}
type=semver,prefix=v,pattern={{major}}.{{minor}}
type=semver,prefix=v,pattern={{major}}.{{minor}}.{{patch}}
type=ref,event=branch
type=sha,prefix=git-,format=short
- name: Download buildctl
shell: bash
run: curl -sL https://github.com/moby/buildkit/releases/download/v0.9.0/buildkit-v0.9.0.linux-amd64.tar.gz | tar xvzf - -C /usr/local bin/buildctl
- name: Move target
working-directory: ${{ inputs.working-dir || inputs.image-name }}/
shell: bash
run: |
export TARGET="${{ inputs.dockerfile || 'Dockerfile' }}"
if [[ "${TARGET}" != 'Dockerfile' ]]; then
mv "${TARGET}" Dockerfile
fi
- name: Set tag in Dockerfile
working-directory: ${{ inputs.working-dir || inputs.image-name }}/
shell: bash
run: sed -i "s/--TAG--/${{ steps.meta.outputs.version }}/g" Dockerfile
- name: Build and push
working-directory: ${{ inputs.working-dir || inputs.image-name }}/
shell: bash
run: |
buildctl --addr unix:///mnt/buildkit/buildkitd.sock \
build \
--frontend dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--output type=image,\"name=${{ steps.meta.outputs.tags }}\",push=${{ github.event_name != 'pull_request' }} \
--export-cache type=inline \
--import-cache type=registry,ref=cr.nail.science/ml-containers/${{ inputs.image-name }}:${{ steps.meta.outputs.version }}