forked from kamailio/kamailio
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (164 loc) · 5.94 KB
/
alpine.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
name: alpine docker image
on:
schedule:
- cron: '41 3 * * *'
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
IMAGE_NAME: kamailio-ci
SOURCE_BRANCH: ${{ github.ref_name }}
DOCKER_REPO: ghcr.io/kamailio/kamailio-ci
jobs:
# is required nightly build?
# More info at https://stackoverflow.com/questions/63014786/how-to-schedule-a-github-actions-nightly-build-but-run-it-only-when-there-where
check:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: octokit/request-action@v2.x
id: check_last_run
with:
route: GET /repos/{owner}/{repo}/actions/workflows/alpine.yml/runs?per_page=1&status=success
owner: ${{ github.repository_owner }}
repo: kamailio
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Show last execution info
run: |
echo "Last daily build: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha }}"
outputs:
last_sha: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha }}
x86_64:
needs: [check]
if: needs.check.outputs.last_sha != github.sha
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: print latest_commit
run: echo ${{ github.sha }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compile Kamailio source
run: |
git submodule init
git submodule update
cd pkg/docker/alpine
./hooks/pre_build || true
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=ref,event=branch
flavor: |
suffix=
latest=auto
- name: Docker meta "-alpine"
id: meta-alpine
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=ref,event=branch
flavor: |
suffix=-alpine
latest=false
- name: Docker meta "-debug"
id: meta-debug
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=ref,event=branch
flavor: |
suffix=-debug
latest=false
- name: temporal workarround for "-alpine" and "-debug" builds
run: |
sudo chown -R ${USER}:${USER} ${{ github.workspace }}/pkg/docker/alpine
cd pkg/docker/alpine
mkdir repackage
tar xz --directory=repackage -f kamailio_min-without_os_files.tar.gz
rm -f kamailio_min-without_os_files.tar.gz
tar cz --directory=repackage -f kamailio_min-without_os_files.tar.gz $(ls -A repackage)
- name: Prepare local repo for "-debug" build
run: |
docker network create kamailio-build
docker run \
--detach \
--network kamailio-build \
--name local-repo \
--hostname local-repo \
--rm=true \
--volume=${{ github.workspace }}/pkg/docker/alpine/apk_files:/usr/share/nginx/html:ro \
nginx
LOCAL_REPO_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' local-repo)
sed -i -e "s/local-repo/${LOCAL_REPO_IP}/" pkg/docker/alpine/Dockerfile.debug
- name: Create custom builder for "-debug" build
id: local-repo
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=kamailio-build
- name: Build and push "-debug" build
uses: docker/build-push-action@v6
with:
context: pkg/docker/alpine
file: pkg/docker/alpine/Dockerfile.debug
builder: ${{ steps.local-repo.outputs.name }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-debug.outputs.tags }}
labels: ${{ steps.meta-debug.outputs.labels }}
- name: Cleanup after "-debug" build
run: |
docker buildx stop ${{ steps.local-repo.outputs.name }}
docker buildx rm ${{ steps.local-repo.outputs.name }}
docker stop local-repo
docker network rm kamailio-build
- name: Build and push "-alpine" build
uses: docker/build-push-action@v6
with:
context: pkg/docker/alpine
file: pkg/docker/alpine/Dockerfile.alpine
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-alpine.outputs.tags }}
labels: ${{ steps.meta-alpine.outputs.labels }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: pkg/docker/alpine
file: pkg/docker/alpine/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}