Build Docker images on native runners #1
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: Build Docker images on native runners | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'EXP branch name' | |
| default: 'main' | |
| required: true | |
| type: string | |
| tag: | |
| description: 'Docker image tag' | |
| default: '24' | |
| required: true | |
| type: string | |
| env: | |
| REGISTRY_IMAGE: the9cat/exp # The image name | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: # Run on these native architectures | |
| platform: [amd64, arm64] | |
| include: | |
| - platform: amd64 # The current default | |
| runner: ubuntu-24.04 | |
| - platform: arm64 # The current default arm64 hardware | |
| runner: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout this repo | |
| uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| run: | | |
| cd Docker | |
| docker build --platform linux/${{ matrix.platform }} --build-arg BRANCH=${{ vars.EXP_BRANCH }} -t ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }}-${{ matrix.platform }} . | |
| docker push ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }}-${{ matrix.platform }} | |
| post-build: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Create and Push Multiarch Manifest | |
| run: | | |
| docker manifest create ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }} \ | |
| ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }}-amd64 \ | |
| ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }}-arm64 | |
| docker manifest push ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }} |