mirror of
https://github.com/bakito/adguardhome-sync.git
synced 2025-03-04 02:53:27 +08:00
117 lines
4.3 KiB
YAML
117 lines
4.3 KiB
YAML
name: docker-image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
release:
|
|
types:
|
|
- published
|
|
|
|
jobs:
|
|
images:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
build:
|
|
- fromImage: scratch
|
|
tagPrefix: ""
|
|
- fromImage: alpine:latest
|
|
tagPrefix: "alpine-"
|
|
steps:
|
|
- name: Get current date
|
|
id: date
|
|
run: echo "::set-output name=date::$(date --utc +%Y-%m-%dT%H:%M:%SZ)"
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
- name: Login to Quay
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: quay.io
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
- name: Login to ghcr.io
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Modify Dockerfile
|
|
run: |
|
|
sed -i -e "s|FROM scratch|FROM ${{ matrix.build.fromImage }}|g" Dockerfile
|
|
|
|
- name: Build and push ${{github.event.release.tag_name }}
|
|
id: docker_build_release
|
|
uses: docker/build-push-action@v2
|
|
if: ${{ github.event.release.tag_name != '' }}
|
|
with:
|
|
context: .
|
|
pull: true
|
|
push: true
|
|
tags: quay.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}latest,quay.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}${{ github.event.release.tag_name }},ghcr.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}latest,ghcr.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}${{ github.event.release.tag_name }}
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
build-args: |
|
|
VERSION=${{ github.event.release.tag_name }}
|
|
BUILD=${{ steps.date.outputs.date }}
|
|
|
|
- name: Build and push main
|
|
id: docker_build_main
|
|
uses: docker/build-push-action@v2
|
|
if: ${{ github.event.release.tag_name == '' }}
|
|
with:
|
|
context: .
|
|
pull: true
|
|
push: true
|
|
tags: quay.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}main,ghcr.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}main
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
build-args: |
|
|
VERSION=main
|
|
BUILD=${{ steps.date.outputs.date }}
|
|
|
|
- name: Image digest
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
test:
|
|
needs: images
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Create kind cluster
|
|
uses: helm/kind-action@v1.3.0
|
|
with:
|
|
version: v0.14.0
|
|
kubectl_version: v1.24.0
|
|
- name: Start adguardhome instances
|
|
run: |
|
|
kubectl create namespace agh
|
|
kubectl config set-context --current --namespace=agh
|
|
kubectl create configmap origin-conf -n agh --from-file testdata/e2e/AdGuardHome.yaml
|
|
kubectl apply -f testdata/e2e/agh
|
|
kubectl wait --for condition=Ready pod/adguardhome-origin --timeout=30s
|
|
kubectl wait --for condition=Ready pod/adguardhome-replica --timeout=30s
|
|
- name: Start adguardhome-sync
|
|
run: |
|
|
kubectl create configmap sync-conf --from-env-file=testdata/e2e/sync-conf.properties
|
|
kubectl apply -f testdata/e2e/pod-adguardhome-sync.yaml
|
|
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/adguardhome-sync --timeout=30s
|
|
- name: Show origin Logs
|
|
run: |
|
|
echo adguardhome-origin
|
|
kubectl logs adguardhome-origin
|
|
- name: Show Replica Logs
|
|
run: |
|
|
echo adguardhome-replica
|
|
kubectl logs adguardhome-replica
|
|
ERRORS=$(kubectl logs adguardhome-replica | grep '\[error\]' | wc -l)
|
|
echo "Found ${ERRORS} error(s) in log";
|
|
- name: Show Sync Logs
|
|
run: |
|
|
echo adguardhome-sync
|
|
kubectl logs adguardhome-sync
|
|
ERRORS=$(kubectl logs adguardhome-sync | grep Error | wc -l)
|
|
echo "Found ${ERRORS} error(s) in log";
|
|
if [[ "${ERRORS}" != "0" ]]; then exit 1; fi
|