Combine nightly and main workflows into one. Tested functionality on a fork so this can come straight into dev

use dev images for the dev branch build.
Only disable pihole checkout on released tags - allow it in dev and nightly tags

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner
2021-11-17 23:42:49 +00:00
parent ff776c2ba4
commit 27bdf81665
3 changed files with 43 additions and 85 deletions

View File

@@ -1,5 +1,7 @@
name: Test & Build
on:
schedule:
- cron: '0 2 * * *'
push:
branches:
- dev
@@ -7,6 +9,7 @@ on:
release:
types: [published]
jobs:
test:
runs-on: ubuntu-latest
@@ -30,31 +33,50 @@ jobs:
name: Checkout
uses: actions/checkout@v2
-
name: Get the tag name
name: Calculate the versions to use
id: variables
run: |
echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ secrets.DOCKERHUB_NAMESPACE }}/pihole
ghcr.io/${{ github.repository_owner }}/pihole
github-token: ${{ secrets.GITHUB_TOKEN }}
# If trigged by schedule then container tag will be nightly, else it's either dev or whatever the tagged version number is
PIHOLE_VERSION=$([ "${{ github.event_name == 'schedule' }}" = "true" ] && echo "nightly" || echo "${GITHUB_REF#refs/*/}")
# If we are building dev branch or nightly then we want to use the development branches of the core components
# otherwise they will be unset and the main branches will be pulled
if [ "${PIHOLE_VERSION}" = "dev" || "${PIHOLE_VERSION}" = "nightly" ]; then
CORE_VERSION=development
WEB_VERSION=devel
FTL_VERSION=development
fi
echo ::set-output name=CORE_VERSION::${CORE_VERSION}
echo ::set-output name=WEB_VERSION::${WEB_VERSION}
echo ::set-output name=FTL_VERSION::${FTL_VERSION}
echo ::set-output name=PIHOLE_VERSION::${PIHOLE_VERSION}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
${{ secrets.DOCKERHUB_NAMESPACE }}/pihole
ghcr.io/${{ github.repository_owner }}/pihole
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}
tags: |
${{ steps.variables.outputs.PIHOLE_VERSION }}
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
-
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
@@ -68,7 +90,10 @@ jobs:
context: .
platforms: linux/amd64, linux/arm64, linux/386, linux/arm/v7, linux/arm/v6, linux/ppc64le
build-args: |
PIHOLE_VERSION=${{ env.TAG }}
CORE_VERSION=${{ steps.variables.outputs.CORE_VERSION }}
WEB_VERSION=${{ steps.variables.outputs.WEB_VERSION }}
FTL_VERSION=${{ steps.variables.outputs.FTL_VERSION }}
PIHOLE_VERSION=${{ steps.variables.outputs.PIHOLE_VERSION }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}