LOCAL STUDENT - cast fix #790
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
| # This workflow builds and tests a multi-architecture Docker image for both AMD64 and ARM64. | |
| # It triggers on pushes to the main, devel, and mulan branches, as well as on version tags. | |
| # Tags are automatically generated based on the triggering event: | |
| # - main branch -> 'latest' | |
| # - devel branch -> 'devel' | |
| # - mulan branch -> 'mulan' | |
| # - version tags (e.g., v1.2.3) -> version number (e.g., '1.2.3') | |
| name: Build, Test, and Push AudioMuse AI Docker Image INTEL and ARM | |
| on: | |
| push: | |
| # We avoid triggering this workflow on direct pushes to `main` to prevent | |
| # accidental builds from routine commits. Keep `devel` and `mulan` as before. | |
| branches: | |
| - devel # Trigger for 'devel' tag | |
| - mulan # New branch also triggers for 'mulan' tag | |
| tags: | |
| - 'v*.*.*' # Trigger for version tags like v1.0.0 | |
| # Allow manual runs for debugging or manual pushes | |
| workflow_dispatch: | |
| jobs: | |
| build-test-and-push: | |
| runs-on: ubuntu-latest # Run on a single AMD64 runner | |
| permissions: | |
| contents: read # Allow checkout to read repository contents | |
| packages: write # Allow pushing packages to GitHub Container Registry | |
| steps: | |
| - name: Check initial disk space | |
| run: | | |
| echo "Disk space before cleanup:" | |
| df -h | |
| - name: Free Disk Space (Ubuntu) | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| swap-storage: false | |
| large-packages: true # Remove large packages (saves ~8-10 GB) | |
| tool-cache: true | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| docker-images: true | |
| - name: Check disk space after cleanup | |
| run: | | |
| echo "Disk space after cleanup:" | |
| df -h | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| # QEMU is used for cross-platform builds (e.g., building ARM on an x86 runner) | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| # Buildx is a Docker CLI plugin that extends the docker command with the full support of the features provided by Moby BuildKit. | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| driver-opts: image=moby/buildkit:latest | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # This new step uses a shell command to reliably convert the repository name to lower case. | |
| - name: Set lower-case repository name | |
| id: repo_name | |
| run: echo "name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| # This step uses the lower-case name from the previous step to generate tags. | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ steps.repo_name.outputs.name }} | |
| tags: | | |
| # When a version tag (refs/tags/v*) is pushed, emit both 'latest' and the semver tag. | |
| # We removed direct main branch triggers, so enable latest on tag pushes. | |
| type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
| # Set 'devel' tag only for the devel branch | |
| type=raw,value=devel,enable=${{ github.ref == 'refs/heads/devel' }} | |
| # Set 'mulan' tag only for the mulan branch | |
| type=raw,value=mulan,enable=${{ github.ref == 'refs/heads/mulan' }} | |
| # Use the version number for Git tags (e.g., v1.2.3 -> 1.2.3) | |
| type=semver,pattern={{version}} | |
| - name: Build and push AudioMuse AI Image | |
| id: docker_build_and_push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: Dockerfile | |
| platforms: linux/amd64,linux/arm64 # Build for both Intel and ARM | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} # Use tags generated by the metadata-action | |
| labels: ${{ steps.meta.outputs.labels }} # Add labels generated by the metadata-action | |
| cache-from: type=gha,scope=${{ github.ref_name }} | |
| cache-to: type=gha,scope=${{ github.ref_name }},mode=max | |
| - name: Final cleanup | |
| if: always() | |
| run: | | |
| echo "Final disk space:" | |
| df -h |