-
Notifications
You must be signed in to change notification settings - Fork 10
96 lines (85 loc) · 2.23 KB
/
Copy pathbuild-image.yaml
File metadata and controls
96 lines (85 loc) · 2.23 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
name: "Build Docker Image"
on:
pull_request:
types: [ opened, synchronize ]
paths-ignore:
- '.run/**'
- 'docs/**'
- 'deployments/**'
- 'scripts/**'
- '*.md'
branches:
- main
- v2
push:
paths-ignore:
- '.run/**'
- 'docs/**'
- 'deployments/**'
- 'scripts/**'
- '*.md'
branches:
- main
- v2
workflow_dispatch:
jobs:
build:
name: Build a Docker image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/arm64/v8
- linux/arm
- linux/arm64
- linux/amd64
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v5
with:
path: go-build-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
- name: inject go-build-cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.3.2
with:
cache-map: |
{
"go-build-cache": "/root/.cache/go-build"
}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
xblaz3kx/chargepi
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,event=pr
flavor: |
latest=true
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
target: chargepi
file: ./build/Dockerfile
platforms: ${{ matrix.platform }}
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max