name: build-image on: push: branches: - "image-buildx" jobs: buildx: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: submodules: true - uses: docker/setup-qemu-action@v1 - uses: docker/setup-buildx-action@v1 with: driver-opts: network=host - id: prepare name: Build binaries && Prepare env: GITHUB_REF: ${{ github.sha }} GITHUB_SHA: ${{ github.ref }} TARGET_PLATFORMS: linux/amd64,linux/arm64 run: |- export TAG=${GITHUB_SHA::7} if [[ ${{ github.ref }} == "refs/tags/v"* ]]; then TAG=$(echo ${{ github.ref }} | sed -e "s/refs\/tags\///") fi echo ::set-output name=target_platforms::${TARGET_PLATFORMS} echo ::set-output name=tag::${TAG} - uses: docker/login-action@v1 name: Login docker.io with: password: ${{ secrets.DOCKER_PASSWORD }} registry: docker.io username: ${{ secrets.DOCKER_USERNAME }} - uses: docker/build-push-action@v2 name: Build image && May Push with: file: Dockerfile.docker-buildx context: . labels: |- org.opencontainers.image.source=https://github.com/${{ github.repository }} org.opencontainers.image.revision=${{ github.sha }} platforms: ${{ steps.prepare.outputs.target_platforms }} push: ${{ github.event_name != 'pull_request' }} tags: | docker.io/${{ github.repository }}:${{ steps.prepare.outputs.tag }}