Docker CI Image Refresh #314
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker CI Image Refresh | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 1 * * *' | |
env: | |
DOCKER_REGISTRY: "docker.internal.networkradius.com" | |
DOCKER_IMAGE_NAME: "docker.internal.networkradius.com/self-hosted" | |
DOCKER_BASE_IMAGE: "ubuntu:20.04" | |
DOCKER_EXTRA_IMAGES: "mariadb postgres 4teamwork/389ds" | |
jobs: | |
build-image: | |
timeout-minutes: 20 | |
runs-on: self-hosted | |
if: github.event_name == 'workflow_dispatch' || github.repository_owner == 'FreeRADIUS' | |
name: "build-docker-image" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
lfs: false | |
- name: Fetch images | |
shell: bash | |
run: | | |
docker pull "$DOCKER_BASE_IMAGE" | |
docker tag "$DOCKER_BASE_IMAGE" "$DOCKER_REGISTRY/$DOCKER_BASE_IMAGE" | |
for IMAGE in $DOCKER_EXTRA_IMAGES; do \ | |
docker pull "$IMAGE"; \ | |
docker tag "$IMAGE" "$DOCKER_REGISTRY/$IMAGE"; \ | |
done | |
- name: Create build dependency package | |
uses: addnab/docker-run-action@v3 | |
with: | |
options: -v ${{ github.workspace }}:/work | |
image: ${{ env.DOCKER_BASE_IMAGE }} | |
run: | | |
apt-get update | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get install -y --no-install-recommends build-essential devscripts equivs quilt | |
cd /work | |
debian/rules debian/control | |
mk-build-deps debian/control | |
mv freeradius-build-deps_*.deb freeradius-build-deps.deb | |
mk-build-deps scripts/ci/extra-packages.debian.control | |
mv freeradius-build-deps_1*.deb freeradius-build-deps-extra.deb | |
chown $(stat -c'%u:%g' .git) * | |
- name: Build Docker image | |
shell: bash | |
run: | | |
docker build --no-cache -f scripts/ci/Dockerfile -t "$DOCKER_IMAGE_NAME" . | |
- name: Docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_REPO_UPDATE_USERNAME }} | |
password: ${{ secrets.DOCKER_REPO_UPDATE_PASSWORD }} | |
registry: ${{ env.DOCKER_REGISTRY }} | |
- name: Push images to local registry | |
shell: bash | |
run: | | |
docker push "$DOCKER_IMAGE_NAME" | |
docker push "$DOCKER_REGISTRY/$DOCKER_BASE_IMAGE" | |
for IMAGE in $DOCKER_EXTRA_IMAGES; do \ | |
docker push "$DOCKER_REGISTRY/$IMAGE"; \ | |
done |