Build and push images #39
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: Build and push images | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| docker_repository: | |
| description: "Docker registry repository" | |
| required: true | |
| type: string | |
| default: apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com | |
| image_tag: | |
| description: "Docker image tag" | |
| required: true | |
| type: string | |
| default: apecloud/ape-dts:latest | |
| platforms: | |
| description: "Target platforms for multi-arch build" | |
| required: true | |
| type: string | |
| default: linux/arm64,linux/amd64 | |
| jobs: | |
| build: | |
| name: Cross build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install cross | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cross | |
| - name: Build for x86_64 | |
| if: contains(inputs.platforms, 'linux/amd64') | |
| run: | | |
| cross build --target x86_64-unknown-linux-gnu --release --features metrics | |
| cp target/x86_64-unknown-linux-gnu/release/dt-main amd64-unknown-linux-gnu-dt-main | |
| - name: Build for aarch64 | |
| if: contains(inputs.platforms, 'linux/arm64') | |
| run: | | |
| cross build --target aarch64-unknown-linux-gnu --release --features metrics | |
| cp target/aarch64-unknown-linux-gnu/release/dt-main arm64-unknown-linux-gnu-dt-main | |
| - name: Set up docker buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build and push docker image | |
| run: | | |
| docker login --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASSWORD }} ${{ inputs.docker_repository }} | |
| docker buildx build -f Dockerfile.github.workflow --platform ${{ inputs.platforms }} --tag ${{ inputs.docker_repository }}/${{ inputs.image_tag }} --push . |