-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (70 loc) · 2.33 KB
/
Copy pathdocker-build.yml
File metadata and controls
81 lines (70 loc) · 2.33 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
name: Docker Build and Push
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
env:
REGISTRY: quay.io
IMAGE_NAME: rhacs-eng/roxie
jobs:
docker-build-push:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
name: Build and Push Multi-arch Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Quay.io
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Get build metadata
id: build-meta
run: |
echo "version=$(make version)" >> $GITHUB_OUTPUT
echo "build_date=$(make get-build-date)" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Tag with 'latest' for main branch.
type=raw,value=latest,enable={{is_default_branch}}
# Tag with version string from 'make version'.
type=raw,value=${{ steps.build-meta.outputs.version }}
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
ROXIE_VERSION=${{ steps.build-meta.outputs.version }}
BUILD_DATE=${{ steps.build-meta.outputs.build_date }}
cache-from: |
type=gha
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=gha,mode=max
- name: Image digest
run: echo "Image pushed with digest ${{ steps.docker_build.outputs.digest }}"