adguardhome-sync/.github/workflows/publish.yml

97 lines
3.2 KiB
YAML
Raw Normal View History

name: docker-image
2021-04-06 01:26:35 +08:00
on:
push:
branches:
- main
2021-04-06 01:26:35 +08:00
release:
types:
- published
jobs:
2022-03-31 03:54:53 +08:00
images:
2021-04-06 01:26:35 +08:00
runs-on: ubuntu-latest
2022-03-31 03:54:53 +08:00
strategy:
matrix:
build:
- fromImage: scratch
tagPrefix: ""
- fromImage: alpine:latest
tagPrefix: "alpine-"
2021-04-06 01:26:35 +08:00
steps:
2021-08-10 00:15:24 +08:00
- name: Get current date
2022-10-13 05:50:08 +08:00
run: echo "curr_date=$(date --utc +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
2021-04-06 01:26:35 +08:00
- name: Set up QEMU
2022-10-13 05:50:08 +08:00
uses: docker/setup-qemu-action@v2
2021-04-06 01:26:35 +08:00
- name: Set up Docker Buildx
2022-10-13 05:50:08 +08:00
uses: docker/setup-buildx-action@v2
2021-04-06 01:26:35 +08:00
- name: Login to Quay
2022-10-13 05:50:08 +08:00
uses: docker/login-action@v2
2021-04-06 01:26:35 +08:00
with:
registry: quay.io
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Login to ghcr.io
2022-10-13 05:50:08 +08:00
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
2022-03-31 03:54:53 +08:00
- name: Checkout
uses: actions/checkout@v3
2022-03-31 03:54:53 +08:00
- name: Modify Dockerfile
run: |
sed -i -e "s|FROM scratch|FROM ${{ matrix.build.fromImage }}|g" Dockerfile
2022-03-15 03:08:55 +08:00
2021-04-06 01:26:35 +08:00
- name: Build and push ${{github.event.release.tag_name }}
id: docker_build_release
uses: docker/build-push-action@v3
2021-04-06 01:26:35 +08:00
if: ${{ github.event.release.tag_name != '' }}
with:
2022-03-31 03:54:53 +08:00
context: .
2022-01-24 23:56:49 +08:00
pull: true
2021-04-06 01:26:35 +08:00
push: true
2022-03-31 03:54:53 +08:00
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 }}
2021-04-06 01:26:35 +08:00
platforms: linux/amd64,linux/arm64,linux/arm/v7
2021-08-10 00:15:24 +08:00
build-args: |
VERSION=${{ github.event.release.tag_name }}
2022-10-13 05:50:08 +08:00
BUILD=${{ env.curr_date }}
2021-04-06 01:26:35 +08:00
- name: Build and push main
id: docker_build_main
uses: docker/build-push-action@v3
2021-04-06 01:26:35 +08:00
if: ${{ github.event.release.tag_name == '' }}
with:
2022-03-31 03:54:53 +08:00
context: .
2022-01-24 23:56:49 +08:00
pull: true
2021-04-06 01:26:35 +08:00
push: true
2022-03-31 03:54:53 +08:00
tags: quay.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}main,ghcr.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}main
2021-04-06 01:26:35 +08:00
platforms: linux/amd64,linux/arm64,linux/arm/v7
2021-08-10 00:15:24 +08:00
build-args: |
VERSION=main
2022-10-13 05:50:08 +08:00
BUILD=${{ env.curr_date }}
2022-03-15 03:08:55 +08:00
2021-04-06 01:26:35 +08:00
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
test:
needs: images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create kind cluster
uses: helm/kind-action@v1.4.0
with:
version: v0.14.0
kubectl_version: v1.24.0
2022-10-07 03:29:04 +08:00
- name: Install Helm Chart
2022-10-07 13:32:20 +08:00
run: ./testdata/e2e/bin/install-chart.sh
2022-10-07 03:29:04 +08:00
- name: Wait for sync to finish
2022-10-07 13:32:20 +08:00
run: ./testdata/e2e/bin/wait-for-sync.sh
- name: Show origin Logs
2022-10-07 13:32:20 +08:00
run: ./testdata/e2e/bin/show-origin-logs.sh
- name: Show Replica Logs
2022-10-07 13:32:20 +08:00
run: ./testdata/e2e/bin/show-replica-logs.sh
- name: Show Sync Logs
2022-10-07 13:32:20 +08:00
run: ./testdata/e2e/bin/show-sync-logs.sh