-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (129 loc) · 4.4 KB
/
build.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
name: Build
on:
schedule:
- cron: "0 5 * * 1"
workflow_call:
workflow_dispatch:
jobs:
build-image:
name: Build images and push to registry
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Create new buildx builder
uses: docker/setup-buildx-action@v2
- name: Generate app image tags
uses: docker/metadata-action@v4
id: meta-app
with:
bake-target: app
images: |
ghcr.io/${{ github.repository }}-app
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
- name: Generate web image tags
uses: docker/metadata-action@v4
id: meta-web
with:
bake-target: web
images: |
ghcr.io/${{ github.repository }}-web
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
- name: Generate cache tag for app image
uses: docker/metadata-action@v4
id: cache-tag-app
with:
images: |
ghcr.io/${{ github.repository }}-app
tags: |
type=ref,event=branch
type=raw,enable=${{ github.ref_type == 'tag' }},value=${{ github.event.repository.default_branch }}
flavor:
suffix=-cache
- name: Generate cache tag for web image
uses: docker/metadata-action@v4
id: cache-tag-web
with:
images: |
ghcr.io/${{ github.repository }}-web
tags: |
type=ref,event=branch
type=raw,enable=${{ github.ref_type == 'tag' }},value=${{ github.event.repository.default_branch }}
flavor:
suffix=-cache
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/[email protected]
with:
targets: release
files: |
./docker-bake.hcl
${{ steps.meta-app.outputs.bake-file }}
${{ steps.meta-web.outputs.bake-file }}
set: |
*.platform=linux/amd64
app.cache-from=type=registry,ref=${{ steps.cache-tag-app.outputs.tags }}
app.cache-to=type=registry,ref=${{ steps.cache-tag-app.outputs.tags }},mode=max
web.cache-from=type=registry,ref=${{ steps.cache-tag-web.outputs.tags }}
web.cache-to=type=registry,ref=${{ steps.cache-tag-web.outputs.tags }},mode=max
push: true
build-deploy:
name: Build NS8 deploy image
runs-on: ubuntu-22.04
needs: build-image
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Generate tags
uses: docker/metadata-action@v4
id: meta
with:
images: |
ghcr.io/nethserver/ns8-phonehome
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Generate Phonehome image tags
uses: docker/metadata-action@v4
id: phonehome-tags
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image with buildah
env:
TAGS: ${{ steps.meta.outputs.tags }}
LABELS: ${{ steps.meta.outputs.labels }}
ARGS: |
PHONEHOME_TAG=${{ steps.phonehome-tags.outputs.version }}
PHONEHOME_SERVER_APP=${{ steps.phonehome-tags.outputs.tags }}-app
PHONEHOME_SERVER_WEB=${{ steps.phonehome-tags.outputs.tags }}-web
working-directory: deploy/ns8
run: |
./build-images.sh
- name: Push image to registry
run: |
PUSH_TAGS='${{ steps.meta.outputs.tags }}'
for tag in $PUSH_TAGS; do
podman push "$tag"
done