Fix Dockerfile #6
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: CI | |
| on: | |
| pull_request: | |
| paths: | |
| - 'Dockerfile' | |
| - 'src/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - '.github/workflows/ci.yml' | |
| push: | |
| branches: | |
| - 'master' | |
| tags: | |
| - v* | |
| env: | |
| CARGO_INCREMENTAL: 0 | |
| RUST_CACHE_VERSION: v1 | |
| REGISTRY_IMAGE: ghcr.io/eewbot/eew-renderer | |
| jobs: | |
| rust: | |
| continue-on-error: false | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - ghimage: ubuntu-24.04 | |
| dockerarch: linux/amd64 | |
| mcarch: amd64 | |
| - ghimage: ubuntu-24.04-arm | |
| dockerarch: linux/arm64 | |
| mcarch: arm64 | |
| permissions: | |
| packages: write | |
| checks: write | |
| contents: read | |
| deployments: write | |
| runs-on: ${{ matrix.ghimage }} | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| - name: Get Rust toolchain | |
| id: toolchain | |
| run: | | |
| awk -F'[ ="]+' '$1 == "channel" { print "toolchain=" $2 }' rust-toolchain >> "$GITHUB_OUTPUT" | |
| - name: install clippy | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ steps.toolchain.outputs.toolchain }} | |
| components: clippy | |
| - name: cache dependencies | |
| uses: Swatinem/rust-cache@v2.7.8 | |
| with: | |
| prefix-key: ${{ env.RUST_CACHE_VERSION }}-rust | |
| - name: clippy check | |
| uses: yanorei32/action-clippy@50412b135153ebee7d4b8a5b868c4defdc663683 | |
| with: | |
| reporter: github-check | |
| - name: unit test | |
| run: | | |
| cargo test --no-run --locked | |
| cargo test | |
| - name: release build | |
| run: cargo build --release | |
| docker_build: | |
| continue-on-error: false | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - ghimage: ubuntu-24.04 | |
| dockerarch: linux/amd64 | |
| mcarch: amd64 | |
| - ghimage: ubuntu-24.04-arm | |
| dockerarch: linux/arm64 | |
| mcarch: arm64 | |
| permissions: | |
| packages: write | |
| checks: write | |
| contents: read | |
| deployments: write | |
| runs-on: ${{ matrix.ghimage }} | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| - uses: docker/metadata-action@v5.7.0 | |
| id: meta | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=sha | |
| - uses: docker/setup-buildx-action@v3.10.0 | |
| - uses: docker/login-action@v3.4.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and Push | |
| uses: docker/build-push-action@v6.15.0 | |
| if: "! startsWith(github.ref, 'refs/pull/')" | |
| id: build | |
| with: | |
| context: . | |
| platforms: ${{ matrix.dockerimage }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Export Digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: digests-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| docker_merge: | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - docker_build | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4.3.0 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| - uses: docker/setup-buildx-action@v3.10.0 | |
| - uses: docker/metadata-action@v5.7.0 | |
| id: meta | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Create manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |