| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- ---
- 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/[email protected]
- 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 }}
- - run: |
- echo Last daily build: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha }}
- echo commit_message: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_commit.message }}
- echo display_title: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].display_title }}
- echo conclusion: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].conclusion }}
- 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 }}
|