This repository was archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
115 lines (115 loc) · 3.67 KB
/
build.yaml
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
name: 'Container image'
on:
push:
branches:
- main
tags:
- '**'
paths-ignore:
- README.md
pull_request:
paths-ignore:
- README.md
jobs:
build:
runs-on: ubuntu-latest
env:
PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: ${{ env.PLATFORMS }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
config-inline: |
[worker.oci]
max-parallelism = 4
driver-opts: network=host
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Cache Docker layers
uses: actions/cache@v2
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-ghcache-
- run: cat ./hack/Makefile
- name: Build candidate image
id: build_candidate
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Inspect candidate image
run: |
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2:latest
- name: Test candidate image
id: test_candidate
run: |
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2 make test
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compose release candidate metadata
id: meta
uses: docker/metadata-action@v3
if: github.event_name != 'pull_request'
with:
images: |
ghcr.io/${{ github.repository_owner }}/golang-with-libgit2
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=sha
type=sha,format=long
- name: Release candidate image
id: release_candidate
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache