2020-06-04 23:03:48 +02:00
|
|
|
name: Test & Build
|
|
|
|
on:
|
2021-11-18 00:42:49 +01:00
|
|
|
schedule:
|
|
|
|
- cron: '0 2 * * *'
|
2020-06-04 23:03:48 +02:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- dev
|
|
|
|
pull_request:
|
2021-09-12 00:30:26 +02:00
|
|
|
release:
|
|
|
|
types: [published]
|
2020-06-04 23:03:48 +02:00
|
|
|
|
|
|
|
jobs:
|
2021-09-12 23:34:24 +02:00
|
|
|
test:
|
2020-06-04 23:03:48 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout Repo
|
2022-04-04 22:46:18 +02:00
|
|
|
uses: actions/checkout@v3
|
2020-06-04 23:03:48 +02:00
|
|
|
- name: Run Tests
|
|
|
|
run: |
|
2022-07-15 18:37:52 +02:00
|
|
|
echo "Building image to test"
|
|
|
|
./build-and-test.sh
|
2020-06-04 23:03:48 +02:00
|
|
|
|
2021-09-12 23:34:24 +02:00
|
|
|
build-and-publish:
|
2020-07-18 04:41:57 +02:00
|
|
|
if: github.event_name != 'pull_request'
|
2022-08-01 19:37:17 +02:00
|
|
|
# If only readme has been touched, for example, then the `test` job will have been skipped. This job will therefore be skipped, too.
|
2021-09-12 23:34:24 +02:00
|
|
|
needs: test
|
2020-06-04 23:03:48 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-10-03 23:15:30 +02:00
|
|
|
-
|
|
|
|
name: Checkout
|
2021-12-10 21:51:35 +01:00
|
|
|
if: github.event_name != 'schedule'
|
2022-04-04 22:46:18 +02:00
|
|
|
uses: actions/checkout@v3
|
2021-10-03 23:15:30 +02:00
|
|
|
-
|
2021-12-10 21:51:35 +01:00
|
|
|
name: Checkout dev branch if we are building nightly
|
|
|
|
if: github.event_name == 'schedule'
|
2022-04-04 22:46:18 +02:00
|
|
|
uses: actions/checkout@v3
|
2021-12-10 21:51:35 +01:00
|
|
|
with:
|
|
|
|
ref: dev
|
2021-11-18 00:42:49 +01:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2022-05-09 08:14:49 +02:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2021-11-18 00:42:49 +01:00
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
2022-05-09 08:14:43 +02:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2021-10-03 23:15:30 +02:00
|
|
|
-
|
|
|
|
name: Docker meta
|
2021-09-13 00:27:06 +02:00
|
|
|
id: meta
|
2022-05-09 08:14:40 +02:00
|
|
|
uses: docker/metadata-action@v4
|
2021-09-13 00:27:06 +02:00
|
|
|
with:
|
2021-11-18 00:42:49 +01:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
2021-10-31 15:39:56 +01:00
|
|
|
images: |
|
|
|
|
${{ secrets.DOCKERHUB_NAMESPACE }}/pihole
|
|
|
|
ghcr.io/${{ github.repository_owner }}/pihole
|
2021-11-18 00:42:49 +01:00
|
|
|
flavor: |
|
|
|
|
latest=${{ startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
tags: |
|
2021-12-10 21:51:35 +01:00
|
|
|
type=schedule
|
2021-12-25 14:38:10 +01:00
|
|
|
type=ref,event=branch,enable=${{ github.event_name != 'schedule' }}
|
2021-12-10 21:51:35 +01:00
|
|
|
type=ref,event=tag
|
2021-10-03 23:15:30 +02:00
|
|
|
-
|
|
|
|
name: Login to DockerHub
|
2022-05-09 08:14:46 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-09-12 23:34:24 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USER }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_PASS }}
|
2021-11-18 00:42:49 +01:00
|
|
|
-
|
2021-10-31 15:39:56 +01:00
|
|
|
name: Login to GitHub Container Registry
|
2022-05-09 08:14:46 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-10-31 15:39:56 +01:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2021-10-03 23:15:30 +02:00
|
|
|
-
|
|
|
|
name: Build and push
|
2022-07-24 01:09:23 +02:00
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
|
|
|
context: ./src/
|
|
|
|
platforms: linux/amd64, linux/arm64, linux/386, linux/arm/v7, linux/arm/v6
|
|
|
|
build-args: |
|
|
|
|
PIHOLE_DOCKER_TAG=${{ steps.meta.outputs.version }}
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|