Nightly Build #148
This file contains hidden or 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
| # Nightly Build — Docker Desktop Extension | |
| # | |
| # Builds and pushes a nightly Docker image from main to GHCR. | |
| # Skips if no commits in the last 24 hours (unless manually triggered). | |
| # | |
| # Prerequisites: | |
| # - Dockerfile at repo root | |
| # - GITHUB_TOKEN has packages:write (automatic for GHCR) | |
| name: Nightly Build | |
| on: | |
| schedule: | |
| - cron: '0 2 * * *' # Every day at 2 AM UTC | |
| workflow_dispatch: # Manual trigger | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| check-changes: | |
| name: Check for Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_changes: ${{ steps.check.outputs.has_changes }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for commits since last nightly | |
| id: check | |
| run: | | |
| # Skip build if no commits in the last 24 hours | |
| RECENT=$(git log --since="24 hours ago" --oneline origin/main | head -1) | |
| if [ -n "$RECENT" ]; then | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| echo "Changes found since last nightly" | |
| else | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| echo "No changes in last 24 hours, skipping build" | |
| fi | |
| build: | |
| name: Nightly Docker Image | |
| needs: check-changes | |
| if: needs.check-changes.outputs.has_changes == 'true' || github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate build metadata | |
| id: meta | |
| run: | | |
| DATE=$(date -u +%Y%m%d) | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| echo "date=$DATE" >> "$GITHUB_OUTPUT" | |
| echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: | | |
| ghcr.io/herbhall/runbooks:nightly | |
| ghcr.io/herbhall/runbooks:nightly-${{ steps.meta.outputs.date }} | |
| build-args: | | |
| VERSION=nightly-${{ steps.meta.outputs.date }}-${{ steps.meta.outputs.short_sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |