Docker #550
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: Docker | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - v* | |
| schedule: | |
| - cron: '0 16 * * *' # Every day at 16:00 UTC (~09:00 PT) | |
| jobs: | |
| deploy: | |
| name: Docker image build | |
| runs-on: ubuntu-latest | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| DOCKER_CLI_EXPERIMENTAL: enabled | |
| steps: | |
| - name: Free Disk space | |
| run: | | |
| sudo swapoff -a | |
| sudo rm -f /swapfile | |
| sudo rm -rf /opt/hostedtoolcache | |
| sudo apt clean | |
| if [ "$(docker image ls -aq)" ]; then | |
| docker rmi $(docker image ls -aq) | |
| else | |
| echo "No Docker images to remove." | |
| fi | |
| df -h | |
| - name: Checkout code | |
| uses: nschloe/action-cached-lfs-checkout@v1.2.2 | |
| with: | |
| exclude: "scoutbot/*/models/pytorch/" | |
| - uses: docker/setup-qemu-action@v3.3.0 | |
| name: Set up QEMU | |
| id: qemu | |
| with: | |
| image: tonistiigi/binfmt:latest | |
| platforms: all | |
| - uses: docker/setup-buildx-action@v3.8.0 | |
| name: Set up Docker Buildx | |
| id: buildx | |
| - name: Available platforms | |
| run: echo ${{ steps.buildx.outputs.platforms }} | |
| - name: Set default Docker build version | |
| run: echo "IMAGE_TAG=nightly" >> $GITHUB_ENV | |
| # Log into container registries | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: wildmeorg | |
| password: ${{ secrets.WBIA_WILDMEBOT_DOCKER_HUB_TOKEN }} | |
| # Push tagged image to registries | |
| - name: Tagged Docker Hub | |
| if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }} | |
| run: | | |
| VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') | |
| echo "IMAGE_TAG=${VERSION}" >> $GITHUB_ENV | |
| # Push bleeding-edge image to registries | |
| - name: Bleeding Edge Docker Hub | |
| if: github.ref == 'refs/heads/main' | |
| run: echo "IMAGE_TAG=main" >> $GITHUB_ENV | |
| # Push nightly image to registries | |
| - name: Nightly Docker Hub | |
| if: github.event_name == 'schedule' | |
| run: echo "IMAGE_TAG=nightly" >> $GITHUB_ENV | |
| # Build and push images | |
| - name: Build Scoutbot | |
| run: | | |
| docker buildx build \ | |
| -t wildme/scoutbot:${{ env.IMAGE_TAG }} \ | |
| --platform linux/amd64 \ | |
| --push \ | |
| --cache-from=type=local,src=/tmp/.buildx-cache \ | |
| --cache-to=type=local,dest=/tmp/.buildx-cache \ | |
| . | |
| - name: Also push latest image | |
| if: ${{ github.event_name == 'push'}} | |
| run: | | |
| docker buildx build \ | |
| -t wildme/scoutbot:latest \ | |
| --platform linux/amd64 \ | |
| --push \ | |
| --cache-from=type=local,src=/tmp/.buildx-cache \ | |
| --cache-to=type=local,dest=/tmp/.buildx-cache \ | |
| . | |
| - name: Trigger Scout Build | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.GHCR_PAT }} | |
| repository: WildMeOrg/scout | |
| event-type: build-trigger |