-
Notifications
You must be signed in to change notification settings - Fork 6
65 lines (57 loc) · 1.75 KB
/
Copy path_docker.yaml
File metadata and controls
65 lines (57 loc) · 1.75 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
name: Docker
on:
workflow_call:
inputs:
registry:
description: Container registry
type: string
default: ghcr.io
image_name:
description: Image name
type: string
default: ${{ github.repository }}
outputs:
image_tag:
description: The primary image tag built
value: ${{ jobs.build.outputs.image_tag }}
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
image_tag: ${{ steps.meta.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.registry }}/${{ inputs.image_name }}
tags: |
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' }}
type=sha,prefix=,enable=${{ github.event_name != 'release' }}
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Save image artifact
run: |
FIRST_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -1)
docker save -o farm-image.tar "$FIRST_TAG"
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: docker-image
path: farm-image.tar
retention-days: 1