This repository has been 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
131 lines (128 loc) · 4.28 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
name: 'Container image'
on:
push:
branches:
- main
tags:
- '**'
paths-ignore:
- README.md
pull_request:
paths-ignore:
- README.md
permissions:
packages: write # needed for ghcr access
id-token: write # needed for keyless signing
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@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Setup Cosign
uses: sigstore/cosign-installer@main
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: ${{ env.PLATFORMS }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
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@v3
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-ghcache-
- run: cat ./hack/static.sh
- name: Build candidate image - libgit2 only
id: build_candidate_libgti2_only
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile.libgit2-only
platforms: ${{ env.PLATFORMS }}
push: true
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Inspect candidate images
run: |
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only:latest
- name: Test candidate images
id: test_candidate
run: |
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only LIBGIT2_ONLY=true 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@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compose release candidate metadata - golang-with-libgit2-only
id: meta_libgit2_only
uses: docker/metadata-action@v3
if: github.event_name != 'pull_request'
with:
images: |
ghcr.io/${{ github.repository_owner }}/golang-with-libgit2-only
tags: |
type=semver,pattern=v{{version}}
type=sha
type=sha,format=long
- name: Release candidate image - golang-with-libgit2-only
id: release_candidate_libgit2_only
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile.libgit2-only
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.meta_libgit2_only.outputs.tags }}
labels: ${{ steps.meta_libgit2_only.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
- name: Sign images
env:
COSIGN_EXPERIMENTAL: 1
run: |
array=($(echo ${{ steps.meta_libgit2_all.outputs.tags }} | tr '\n' " "))
for element in "${array[@]}"
do
echo ${element}
cosign sign $element
done