name: Publish Docker Container Images on: push: branches: [main] env: REGISTRY: ghcr.io REPO_NAME: ${{ github.repository }} permissions: contents: read packages: write jobs: # ------------------------------------------------------------------------------------------ # To be decided: Script-Deploy or Dockerfile-Deploy: # Script: # + Separates the golang build from the corso build. # - Haven't figured out multiplatform builds yet. # - Doesn't cache, always takes 10-15 minutes per build in the matrix. # Dockerfile: # + Once cached, takes <1m to deploy. # + Multiplatform. # + Extended features (such as tagging) can be handled by more github actions. # - When not cached, can take >2 hours to build (at least initially). # - Currently includes the complete golang:1.18 image. # ------------------------------------------------------------------------------------------ Script-Deploy: runs-on: ubuntu-latest defaults: run: working-directory: build strategy: matrix: BUILD_ARCH: [amd64, arm64] BUILD_OS: [linux] env: IMAGE_PREFIX: ghcr.io VERSION_SUFFIX: rolling steps: - name: Checkout repository uses: actions/checkout@v3 - name: Run build script run: > ./build-container.sh --arch ${{ matrix.BUILD_ARCH }} --prefix ${{ env.IMAGE_PREFIX }} --suffix ${{ env.VERSION_SUFFIX }} # login step boilerplate from: # https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio - name: Log in to registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - name: Push image env: IMAGE_ID: ${{ env.IMAGE_PREFIX }}/alcionai/corso VERSION: ${{ matrix.BUILD_OS }}-${{ matrix.BUILD_ARCH }}-${{ env.VERSION_SUFFIX }} run: | docker images -a docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }} Dockerfile-Deploy: runs-on: ubuntu-latest env: TARGETOS: linux TARGETARCH: arm64 steps: - name: Checkout repository uses: actions/checkout@v3 # apparently everyone uses this step - name: Set up QEMU uses: docker/setup-qemu-action@v2 # setup Docker buld action - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 # In case we want to switch to dockerhub # - name: Login to DockerHub # uses: docker/login-action@v2 # with: # username: ${{ secrets.DOCKERHUB_USERNAME }} # password: ${{ secrets.DOCKERHUB_TOKEN }} # retrieve credentials for ghcr.io - name: Login to Github Packages uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} # build the image - name: Build image and push to Docker Hub and GitHub Container Registry uses: docker/build-push-action@v3 with: context: . file: ./docker/Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: ghcr.io/alcionai/corso:rolling # use the github cache cache-from: type=gha cache-to: type=gha,mode=max # check the image digest - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }}