Build and publish container #71
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Docker build and publish | |
on: | |
# cron job to trigger the build on any push to main | |
push: | |
branches: | |
- 'main' | |
schedule: | |
# cron job to trigger the build daily | |
# at 3am on Friday | |
- cron: '0 3 * * 5' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Get latest release of pihole docker container | |
id: latest_release | |
env: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: "pi-hole/docker-pi-hole" | |
type: "stable" | |
run: echo release=$(curl --silent "https://api.github.com/repos/pi-hole/docker-pi-hole/releases/latest" | jq -r '.tag_name') >> $GITHUB_OUTPUT | |
- name: Get previous release tag | |
id: previous_release | |
env: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: "aleksanderbl29/docker-pihole-unbound" | |
type: "stable" | |
run: echo release=$(curl --silent "https://api.github.com/repos/aleksanderbl29/docker-pihole-unbound/releases/latest" | jq -r '.tag_name' ) >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
if: ${{ steps.latest_release.outputs.release != steps.previous_release.outputs.release }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
if: ${{ steps.latest_release.outputs.release != steps.previous_release.outputs.release }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
if: ${{ steps.latest_release.outputs.release != steps.previous_release.outputs.release }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: PIHOLE_VERSION=${{ steps.latest_release.outputs.release }} | |
context: "{{defaultContext}}:pihole-unbound/" | |
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 | |
push: true | |
tags: aleksanderbl/pihole-unbound:latest,aleksanderbl/pihole-unbound:${{ steps.latest_release.outputs.release }} | |
if: ${{ steps.latest_release.outputs.release != steps.previous_release.outputs.release }} | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.latest_release.outputs.release }} | |
name: "${{ steps.latest_release.outputs.release }}" | |
body: | | |
Changelog found on [pi-hole github](https://github.com/pi-hole/docker-pi-hole/releases), please read the changes before updating. | |
You can update the docker image with: | |
``` | |
docker compose pull | |
docker compose up -d | |
``` | |
if: ${{ steps.latest_release.outputs.release != steps.previous_release.outputs.release }} |