mirror of
https://github.com/klutchell/unbound-docker.git
synced 2026-10-29 16:14:28 +00:00
149 lines
4.3 KiB
YAML
149 lines
4.3 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "*"
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
branches:
|
|
- "main"
|
|
|
|
env:
|
|
PACKAGE_VERSION: "1.13.1"
|
|
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6"
|
|
|
|
jobs:
|
|
revbot:
|
|
runs-on: ubuntu-20.04
|
|
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- id: revbot
|
|
run: |
|
|
for i in [0..100] ; do \
|
|
new_tag="v${{ env.PACKAGE_VERSION }}+rev${i}" ; \
|
|
git show-ref --tags ${new_tag} --quiet || break ; \
|
|
done
|
|
echo "::set-output name=new_tag::${new_tag}"
|
|
|
|
- uses: rickstaa/action-create-tag@v1
|
|
with:
|
|
tag: "${{ steps.revbot.outputs.new_tag }}"
|
|
|
|
docker-meta:
|
|
runs-on: ubuntu-20.04
|
|
needs: revbot
|
|
|
|
outputs:
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
version: ${{ steps.meta.outputs.version }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- id: meta
|
|
uses: docker/metadata-action@v3
|
|
with:
|
|
images: docker.io/${{ github.repository }},ghcr.io/${{ github.repository }}
|
|
|
|
build:
|
|
runs-on: ubuntu-20.04
|
|
needs: docker-meta
|
|
|
|
steps:
|
|
- name: Free disk space
|
|
run: |
|
|
df --human-readable
|
|
sudo apt clean
|
|
docker rmi $(docker image ls --all --quiet) || true
|
|
rm -rf "${AGENT_TOOLSDIRECTORY}"
|
|
df --human-readable
|
|
|
|
- name: Login to ghcr.io
|
|
uses: docker/login-action@v1
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to docker.io
|
|
uses: docker/login-action@v1
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
registry: docker.io
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- uses: docker/setup-qemu-action@v1
|
|
|
|
- uses: docker/setup-buildx-action@v1
|
|
with:
|
|
driver-opts: network=host
|
|
|
|
- uses: docker/build-push-action@v2
|
|
with:
|
|
platforms: ${{ env.PLATFORMS }}
|
|
labels: ${{ needs.docker-meta.outputs.labels }}
|
|
tags: ${{ needs.docker-meta.outputs.tags }}
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
outputs: type=oci,dest=/tmp/oci.tar
|
|
cache-to: type=gha,mode=max
|
|
cache-from: |
|
|
type=gha
|
|
${{ needs.docker-meta.outputs.tags }}
|
|
|
|
- uses: peter-evans/dockerhub-description@v2
|
|
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
repository: ${{ github.repository }}
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: oci
|
|
path: /tmp/oci.tar
|
|
|
|
test:
|
|
runs-on: ubuntu-20.04
|
|
needs: [docker-meta,build]
|
|
|
|
strategy:
|
|
matrix:
|
|
tag: ${{ fromJson(needs.docker-meta.outputs.json).tags }}
|
|
platform: [linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6]
|
|
|
|
steps:
|
|
- uses: docker/setup-qemu-action@v1
|
|
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
name: oci
|
|
path: /tmp
|
|
|
|
- name: Load ${{ matrix.platform }} manifest
|
|
run: |
|
|
skopeo \
|
|
--override-os "$(echo ${{ matrix.platform }} | awk -F '/' '{print $1}')" \
|
|
--override-arch "$(echo ${{ matrix.platform }} | awk -F '/' '{print $2}')" \
|
|
--override-variant "$(echo ${{ matrix.platform }} | awk -F '/' '{print $3}')" \
|
|
copy "oci-archive:/tmp/oci.tar:${{ matrix.tag }}" "docker-daemon:${{ matrix.tag }}"
|
|
|
|
- name: Test package version
|
|
run: |
|
|
docker run ${{ matrix.tag }} -v | tee /dev/stderr | grep -wq ${{ env.PACKAGE_VERSION }}
|
|
|
|
- name: Test package functionality
|
|
run: |
|
|
docker run -d --name sut ${{ matrix.tag }}
|
|
docker exec sut dig sigok.verteiltesysteme.net @127.0.0.1 +dnssec | tee /dev/stderr | grep -wq NOERROR || { docker logs sut ; exit 1 ; }
|
|
docker exec sut dig sigfail.verteiltesysteme.net @127.0.0.1 +dnssec | tee /dev/stderr | grep -wq SERVFAIL || { docker logs sut ; exit 1 ; }
|
|
docker logs sut
|
|
docker rm -f sut
|