docker-images #764
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-images | |
on: | |
workflow_dispatch: # allows manual triggering | |
schedule: | |
- cron: '0 0 * * *' | |
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 | |
run: echo "curr_date=$(date --utc +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Quay | |
uses: docker/login-action@v3 | |
with: | |
registry: quay.io | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- name: Login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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@v6 | |
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/arm/v6,linux/arm/v7,linux/arm64/v8,linux/arm64,linux/ppc64le | |
provenance: false | |
build-args: | | |
VERSION=${{ github.event.release.tag_name }} | |
BUILD=${{ env.curr_date }} | |
- name: Check for commits in the last 24 hours | |
run: echo "NEW_COMMIT_COUNT=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_ENV | |
if: ${{ github.event.release.tag_name == '' }} | |
- name: Build and push main | |
id: docker_build_main | |
uses: docker/build-push-action@v6 | |
if: ${{ github.event.release.tag_name == '' && env.NEW_COMMIT_COUNT > 0 }} | |
with: | |
context: . | |
pull: true | |
push: ${{ github.ref == 'refs/heads/main' }} | |
tags: quay.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}main,ghcr.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}main | |
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/arm64,linux/ppc64le | |
provenance: false | |
build-args: | | |
VERSION=main | |
BUILD=${{ env.curr_date }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |