daedalus-docker-build #2232
Workflow file for this run
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
| name: daedalus-docker-build | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| paths: | |
| - .github/workflows/daedalus-docker.yml | |
| - 'apps/daedalus_client/**' | |
| - 'packages/daedalus/**' | |
| - Cargo.toml | |
| - Cargo.lock | |
| pull_request: | |
| types: [opened, synchronize] | |
| paths: | |
| - .github/workflows/daedalus-docker.yml | |
| - 'apps/daedalus_client/**' | |
| - 'packages/daedalus/**' | |
| - Cargo.toml | |
| - Cargo.lock | |
| merge_group: | |
| types: [checks_requested] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/prod' }} | |
| jobs: | |
| skip-if-clean: | |
| name: Skip if merge_queue produces no diff | |
| runs-on: ubuntu-latest | |
| outputs: | |
| skip: ${{ steps.check.outputs.skip }} | |
| internal: ${{ steps.check-internal.outputs.internal }} | |
| if: ${{ always() }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Check if workflow runs on an internal branch | |
| id: check-internal | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} | |
| REPO: ${{ github.repository }} | |
| run: | | |
| if [ "$EVENT_NAME" != "pull_request" ] || [ "$HEAD_REPO" = "$REPO" ]; then | |
| echo "internal=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "internal=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Merge Queue CI Check Skipper | |
| id: merge-queue-ci-skipper | |
| uses: ./.github/merge-queue-ci-skipper | |
| with: | |
| secret: ${{ secrets.GH_ACCESS_TOKEN }} | |
| - name: Check merge_group synthetic commit | |
| id: check | |
| run: | | |
| # PR mode: never skip | |
| if [ "${{ github.event_name }}" != "merge_group" ]; then | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| if [ "${{ steps.merge-queue-ci-skipper.outputs.skip-check }}" = "true" ]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| docker: | |
| runs-on: ${{ needs.skip-if-clean.outputs.internal == 'true' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} | |
| env: | |
| SCCACHE_DIR: ${{ needs.skip-if-clean.outputs.internal == 'true' && '/mnt/sccache' || '' }} | |
| SCCACHE_CACHE_SIZE: ${{ needs.skip-if-clean.outputs.internal == 'true' && '10G' || '' }} | |
| RUSTC_WRAPPER: ${{ needs.skip-if-clean.outputs.internal == 'true' && 'sccache' || '' }} | |
| needs: [skip-if-clean] | |
| if: ${{ needs.skip-if-clean.outputs.skip != 'true' }} | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0 | |
| with: | |
| rustflags: '' | |
| cache: false | |
| - name: Setup mold | |
| uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 / Mold 2.41.0 | |
| - name: Cache Cargo registry and index | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| ~/.cargo/bin | |
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Mount sccache disk cache | |
| if: needs.skip-if-clean.outputs.internal == 'true' | |
| uses: useblacksmith/stickydisk@13af8883542ca949a717e70fef89d15edbb29d88 # v1.2.0 | |
| with: | |
| key: ${{ github.repository }}-daedalus-sccache | |
| path: /mnt/sccache | |
| - name: Setup sccache | |
| if: needs.skip-if-clean.outputs.internal == 'true' | |
| uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 | |
| - name: Build daedalus_client | |
| run: cargo build --release --package daedalus_client | |
| - name: Stage Docker context | |
| run: | | |
| mkdir -p apps/daedalus_client/docker-stage | |
| cp target/release/daedalus_client apps/daedalus_client/docker-stage/daedalus_client | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Generate Docker image metadata | |
| id: docker-meta | |
| uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 | |
| env: | |
| DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | |
| with: | |
| images: ghcr.io/modrinth/daedalus | |
| labels: | | |
| org.opencontainers.image.title=daedalus | |
| org.opencontainers.image.description=Modrinth game metadata query client | |
| org.opencontainers.image.licenses=MIT | |
| annotations: | | |
| org.opencontainers.image.title=daedalus | |
| org.opencontainers.image.description=Modrinth game metadata query client | |
| org.opencontainers.image.licenses=MIT | |
| - name: Login to GitHub Packages | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 | |
| with: | |
| context: ./apps/daedalus_client/docker-stage | |
| file: ./apps/daedalus_client/Dockerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.docker-meta.outputs.tags }} | |
| labels: ${{ steps.docker-meta.outputs.labels }} | |
| annotations: ${{ steps.docker-meta.outputs.annotations }} |