name: Nightly on: schedule: # Run at 4am UTC daily - cron: '0 4 * * *' workflow_dispatch: # Allow manual trigger concurrency: group: nightly cancel-in-progress: true env: REGISTRY: ghcr.io # github.repository must be lowercased for Docker registry compatibility IMAGE_NAME: ${{ github.repository_owner }}/tracearr jobs: check-changes: name: Check for changes runs-on: ubuntu-latest outputs: should_build: ${{ steps.check.outputs.should_build }} steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Check if new commits since last nightly id: check run: | # Get commits in last 25 hours (buffer for timing) COMMITS=$(git log --since="25 hours ago" --oneline | wc -l) if [ "$COMMITS" -gt 0 ]; then echo "should_build=true" >> "$GITHUB_OUTPUT" echo "Found $COMMITS new commits" else echo "should_build=false" >> "$GITHUB_OUTPUT" echo "No new commits, skipping build" fi build-and-push: name: Build & Push Docker runs-on: ubuntu-latest needs: [check-changes] if: needs.check-changes.outputs.should_build == 'true' || github.event_name == 'workflow_dispatch' permissions: contents: read packages: write steps: - name: Checkout uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=nightly type=raw,value=nightly-{{date 'YYYYMMDD'}} type=sha,prefix=sha- - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . file: ./docker/Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max build-and-push-supervised: name: Build & Push Supervised Image runs-on: ubuntu-latest needs: [check-changes] if: needs.check-changes.outputs.should_build == 'true' || github.event_name == 'workflow_dispatch' permissions: contents: read packages: write steps: - name: Checkout uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for supervised image id: meta-supervised uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=supervised-nightly type=raw,value=supervised-nightly-{{date 'YYYYMMDD'}} - name: Build and push supervised image uses: docker/build-push-action@v6 with: context: . file: ./docker/Dockerfile.supervised platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta-supervised.outputs.tags }} labels: ${{ steps.meta-supervised.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max