name: Nightly Build on: schedule: # Run at 2 AM UTC every day - cron: '0 2 * * *' workflow_dispatch: inputs: tag_suffix: description: 'Tag suffix for the nightly build (e.g., alpha, beta)' required: false default: 'nightly' env: KO_DOCKER_REPO: ghcr.io/${{ github.repository }}/controller jobs: nightly-build: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 # Full history for accurate versioning - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.24' cache: true - name: Install ko uses: ko-build/setup-ko@v0.6 - 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 ghcr.io uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Generate nightly version id: version run: | # Get the latest tag LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") echo "Latest tag: $LATEST_TAG" # Get commit info SHORT_SHA=$(git rev-parse --short HEAD) COMMIT_DATE=$(git show -s --format=%cs) # Generate nightly version # Format: --- SUFFIX="${{ github.event.inputs.tag_suffix || 'nightly' }}" NIGHTLY_VERSION="${LATEST_TAG}-${COMMIT_DATE}-${SHORT_SHA}-${SUFFIX}" echo "nightly_version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT echo "commit_date=$COMMIT_DATE" >> $GITHUB_OUTPUT # Also create a simple 'nightly' tag that always points to latest echo "latest_tag=nightly" >> $GITHUB_OUTPUT echo "Generated nightly version: $NIGHTLY_VERSION" - name: Build and push multi-arch images env: GOFLAGS: "-ldflags=-X=main.version=${{ steps.version.outputs.nightly_version }}" run: | # Build with nightly version tag ko build \ --platform=linux/amd64,linux/arm64 \ --bare \ --tags=${{ steps.version.outputs.nightly_version }} \ ./cmd/controller # Also tag as 'nightly' for easy reference ko build \ --platform=linux/amd64,linux/arm64 \ --bare \ --tags=${{ steps.version.outputs.latest_tag }} \ ./cmd/controller # Verify the manifests echo "Verifying nightly version manifest..." docker buildx imagetools inspect $KO_DOCKER_REPO:${{ steps.version.outputs.nightly_version }} echo "Verifying latest nightly manifest..." docker buildx imagetools inspect $KO_DOCKER_REPO:${{ steps.version.outputs.latest_tag }} - name: Create build summary run: | cat >> $GITHUB_STEP_SUMMARY < issue.title === title); if (!existingIssue) { await github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, title: title, body: `The nightly build failed on ${date}.\n\nWorkflow run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, labels: ['nightly-build-failure', 'automated'] }); }