-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
91 lines (81 loc) · 2.38 KB
/
action.yml
File metadata and controls
91 lines (81 loc) · 2.38 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
name: "Docker build & push"
description: "Docker build & push"
inputs:
registry:
description: "Docker registry"
required: false
default: ghcr.io/${{ github.repository_owner }}
name:
description: "Docker image name"
required: true
registry_username:
description: "Docker registry username"
required: false
default: ${{ github.actor }}
registry_password:
description: "Docker registry password"
required: true
arch:
description: "Docker image arch"
required: false
default: 'linux/amd64'
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: name=${{ inputs.registry }}/${{ inputs.name }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ inputs.arch }}
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.registry_username }}
password: ${{ inputs.registry_password }}
- name: Build for branch
id: build-branch
if: github.ref_type != 'tag'
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ inputs.arch }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
- name: Build for tag
id: build-tag
if: github.ref_type == 'tag'
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ inputs.arch }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ inputs.registry }}/${{ inputs.name }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
- name: Export digest
if: github.ref_type == 'tag'
shell: bash
run: |
mkdir -p /tmp/digests
digest="${{ steps.build-tag.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
if: github.ref_type == 'tag'
uses: actions/upload-artifact@v4
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1