Fix build for arm64 image #144
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 Test | ||
| on: | ||
| push: | ||
| tags: | ||
| - v* | ||
| branches: | ||
| - develop | ||
| - main | ||
| pull_request: | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| env: | ||
| __W_SRC_REL: go/src/github.com/RocketChat/airlock | ||
| jobs: | ||
| jobs: | ||
| build: | ||
| name: Build and test | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| platform: [linux/amd64, linux/arm64] | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 1 | ||
| path: ${{ env.__W_SRC_REL }} | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: ${{ env.__W_SRC_REL }}/go.mod | ||
| - name: Build binary | ||
| run: | | ||
| cd $__W_SRC_REL | ||
| go mod tidy | ||
| platform=${{ matrix.platform }} | ||
| TARGETOS=${platform%%/*} TARGETARCH=${platform##*/} make build | ||
| - name: Set up QEMU | ||
| if: ${{ matrix.platform == 'linux/arm64' }} | ||
| uses: docker/setup-qemu-action@v3 | ||
| - name: Set up Docker Buildx | ||
| if: ${{ matrix.platform == 'linux/arm64' }} | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Tag arch images | ||
| id: tag | ||
| run: | | ||
| platform=${{ matrix.platform}} | ||
| echo "tag=${platform##*/}" >> $GITHUB_OUTPUT | ||
| - name: Login to Docker Registry | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERREGISTRY_USERNAME }} | ||
| password: ${{ secrets.DOCKERREGISTRY_PASSWORD }} | ||
| - name: Docker build and push | ||
| uses: docker/build-push-action@v3 | ||
| with: | ||
| context: ${{ env.__W_SRC_REL }} | ||
| file: ${{ env.__W_SRC_REL }}/Dockerfile | ||
| platforms: ${{ matrix.platform }} | ||
| push: true | ||
| tags: | | ||
| rocketchat/airlock:${{github.sha}}-${{ steps.tag.outputs.tag }} | ||
| combine-arch-tags: | ||
| needs: [build] | ||
| name: Join platform tags | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Login to Docker Registry | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERREGISTRY_USERNAME }} | ||
| password: ${{ secrets.DOCKERREGISTRY_PASSWORD }} | ||
| - name: Join tags and push | ||
| run: | | ||
| docker buildx imagetools create -t rocketchat/airlock:${{ github.sha }} rocketchat/airlock:${{ github.sha }}-amd64 rocketchat/airlock:${{ github.sha }}-arm64 | ||