Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

Update dockerhub-publish.yaml

Katosa825bab98649
diff --git a/.github/workflows/dockerhub-publish.yaml b/.github/workflows/dockerhub-publish.yaml
index dcf7a6c2..599b0ffa 100644
--- a/.github/workflows/dockerhub-publish.yaml
+++ b/.github/workflows/dockerhub-publish.yaml
@@ -1,48 +1,100 @@
-name: Publish Dockerhub image
+name: Dockerhub publish
on:
- workflow_call:
- release:
- types: [published]
+ schedule:
+ - cron: '00 0 * * *'
+ push:
+ branches: [ "main" ]
+ paths:
+ - 'backend/**'
+ - 'frontend/**'
+ - 'Dockerfile'
+ - 'Dockerfile.rootless'
+ - '.dockerignore'
+ - '.github/workflows'
+ # Publish semver tags as releases.
+ tags: [ 'v*.*.*' ]
+ pull_request:
+ branches: [ "main" ]
+ paths:
+ - 'backend/**'
+ - 'frontend/**'
+ - 'Dockerfile'
+ - 'Dockerfile.rootless'
+ - '.dockerignore'
+ - '.github/workflows'
+
+env:
+ # Use docker.io for Docker Hub
+ REGISTRY: docker.io
+ # Set the image name under sysadminsmedia organization
+ IMAGE_NAME: sysadminsmedia/homebox
jobs:
- push_to_registry:
- name: Push Docker image to Docker Hub
+ build:
+
runs-on: ubuntu-latest
permissions:
- packages: write
contents: read
+ packages: write
+ # This is used to complete the identity challenge
+ # with sigstore/fulcio when running outside of PRs.
attestations: write
id-token: write
+
steps:
- - name: Check out the repo
+ - name: Checkout repository
uses: actions/checkout@v4
- - name: Log in to Docker Hub
- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
+ # Set up BuildKit Docker container builder to be able to build
+ # multi-platform images and export cache
+ - name: Set up Docker Buildx
+ uses: docker/[email protected] # v3.0.0
+
+ # Login against Docker Hub registry
+ - name: Log into Docker Hub
+ if: github.event_name != 'pull_request'
+ uses: docker/[email protected] # v3.0.0
with:
+ registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- - name: Extract metadata (tags, labels) for Docker
+ # Extract metadata (tags, labels) for Docker
+ - name: Extract Docker metadata
id: meta
- uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
+ uses: docker/[email protected] # v5.0.0
with:
- images: my-docker-hub-namespace/my-docker-hub-repository
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ tags: |
+ type=ref,event=branch
+ type=ref,event=pr
+ type=semver,pattern={{version}}
+ type=semver,pattern={{major}}.{{minor}}
+ type=semver,pattern={{major}}
+ type=schedule,pattern=nightly
+ # Build and push Docker image with Buildx (don't push on PR)
- name: Build and push Docker image
- id: push
- uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
+ id: build-and-push
+ uses: docker/[email protected] # v5.0.0
with:
context: .
- file: ./Dockerfile
- push: true
+ push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+ platforms: linux/amd64
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+ build-args: |
+ VERSION=${{ github.ref_name }}
+ COMMIT=${{ github.sha }}
- - name: Generate artifact attestation
- uses: actions/attest-build-provenance@v2
+ - name: Attest
+ uses: actions/attest-build-provenance@v1
+ id: attest
+ if: ${{ github.event_name != 'pull_request' }}
with:
- subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
- subject-digest: ${{ steps.push.outputs.digest }}
+ subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ subject-digest: ${{ steps.build-and-push.outputs.digest }}
push-to-registry: true