name: Build Docker Image on: push: tags: - 'v**' schedule: - cron: '0 1 * * *' jobs: build-and-push-image: name: Docker Build runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Check out code uses: actions/checkout@v4 - name: Check for new commits (nightly only) id: check if: github.event_name == 'schedule' continue-on-error: false run: | # 3AM CET since="$(date -d 'yesterday' +%Y-%m-%d) 01:00:00" count=$(git rev-list --count --since="$since" --until=now HEAD) if [ "$count" -gt 0 ]; then echo "new_commits=true" >> $GITHUB_OUTPUT else echo "no new commits found for nightly build" exit 1 fi - name: Set version id: buildvars run: | if [ "${{ github.event_name }}" = "schedule" ]; then echo "version=$(date +'%Y.%m.%d-nightly')" >> $GITHUB_OUTPUT else echo "version=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT fi echo "built_at=$(date +%Y-%m-%dT%H:%M:%S)" >> $GITHUB_OUTPUT echo "git_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: | ghcr.io/${{ github.repository }}${{ !contains(github.ref, '-rc') && !contains(github.ref, '-nightly') && '-testing' || '' }} - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache build-args: | BuiltAt=${{ steps.buildvars.outputs.built_at }} GitCommit=${{ steps.buildvars.outputs.git_commit }} Version=${{ steps.buildvars.outputs.version }}