-
Notifications
You must be signed in to change notification settings - Fork 20
144 lines (121 loc) · 3.97 KB
/
docker-publish-images.yml
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
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Docker publish
on:
push:
branches:
- 'main'
jobs:
docker-base-image:
runs-on: ubuntu-latest
strategy:
matrix:
component:
- trivy-adapter
- core
- db
- exporter
- jobservice
- log
- nginx
- portal
- prepare
- redis
- registry
- registryctl
defaults:
run:
working-directory: ./harbor
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
with:
driver: docker-container
driver-opts: network=host
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: cd .. && make patch
- id: prepare
run: echo "tag=$(cat ../version)" >> $GITHUB_ENV
- name: Build base image
uses: docker/build-push-action@v4
with:
context: ./harbor
file: ./harbor/make/photon/${{ matrix.component }}/Dockerfile.base
platforms: linux/amd64,linux/arm64
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ env.tag }}
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/${{ github.repository }}/harbor-${{ matrix.component }}-base:${{ env.tag }}
docker-image:
needs:
- docker-base-image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component:
- prepare
- db
- portal
- core
- jobservice
- log
- nginx
- registryctl
- trivy_adapter
- redis
- standalone_db_migrator
- exporter
defaults:
run:
working-directory: ./harbor
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-go@v3
with:
go-version: '^1.20.x'
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
with:
driver: docker-container
driver-opts: network=host
- run: cd .. && make patch
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: prepare
run: echo "tag=$(cat ../version)" >> $GITHUB_ENV
- name: Build & Publish images
env:
IMAGENAMESPACE: ghcr.io/${{ github.repository }}
BASEIMAGENAMESPACE: ghcr.io/${{ github.repository }}
IMAGELABELS: org.opencontainers.image.source=https://github.com/${{ github.repository }}
MULTIARCH: true
TRIVYFLAG: true
CHARTFLAG: true
NOTARYFLAG: true
run: |
set -eux;
CTX="BUILDBIN=true VERSIONTAG=${{ env.tag }} BASEIMAGETAG=${{ env.tag }} MULTIARCH=${MULTIARCH} IMAGENAMESPACE=${IMAGENAMESPACE} BASEIMAGENAMESPACE=${BASEIMAGENAMESPACE} TRIVYFLAG=${TRIVYFLAG} CHARTFLAG=${CHARTFLAG} NOTARYFLAG=${CHARTFLAG} IMAGELABELS=${IMAGELABELS}"
make versions_prepare ${CTX};
case ${{ matrix.component }} in
core) make compile_core ${CTX} ;;
jobservice) make compile_jobservice ${CTX};;
registryctl) make compile_registryctl ${CTX};;
standalone_db_migrator) make compile_standalone_db_migrator ${CTX} ;;
esac;
case ${{ matrix.component }} in
exporter) make build BUILDTARGET="_compile_and_build_exporter" ${CTX} ;;
registryctl) make build BUILDTARGET="_build_registry _build_registryctl" ${CTX} ;;
*) make build BUILDTARGET="_build_${{ matrix.component }}" ${CTX} ;;
esac;