|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + tags: |
| 11 | + - v* |
| 12 | + schedule: |
| 13 | + - cron: '0 16 * * *' # Every day at 16:00 UTC (~09:00 PT) |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Push container image to GitHub Packages and Docker Hub. |
| 17 | + # See also https://docs.docker.com/docker-hub/builds/ |
| 18 | + deploy: |
| 19 | + name: Docker image build |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + env: |
| 23 | + DOCKER_BUILDKIT: 1 |
| 24 | + DOCKER_CLI_EXPERIMENTAL: enabled |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + |
| 29 | + with: |
| 30 | + exclude: "batbot/*/models/pytorch/" |
| 31 | + |
| 32 | + - uses: docker/setup-qemu-action@v1 |
| 33 | + name: Set up QEMU |
| 34 | + id: qemu |
| 35 | + with: |
| 36 | + image: tonistiigi/binfmt:latest |
| 37 | + platforms: all |
| 38 | + |
| 39 | + - uses: docker/setup-buildx-action@v1 |
| 40 | + name: Set up Docker Buildx |
| 41 | + id: buildx |
| 42 | + |
| 43 | + - name: Available platforms |
| 44 | + run: echo ${{ steps.buildx.outputs.platforms }} |
| 45 | + |
| 46 | + # Log into container registries |
| 47 | + - name: Login to DockerHub |
| 48 | + uses: docker/login-action@v1 |
| 49 | + with: |
| 50 | + username: batbot |
| 51 | + password: ${{ secrets.BATBOT_DOCKER_HUB_TOKEN }} |
| 52 | + |
| 53 | + # Push tagged image (version tag + latest) to registries |
| 54 | + - name: Tagged Docker Hub |
| 55 | + if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }} |
| 56 | + run: | |
| 57 | + VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') |
| 58 | + echo "IMAGE_TAG=${VERSION}" >> $GITHUB_ENV |
| 59 | +
|
| 60 | + # Push bleeding-edge image (main tag) to registries |
| 61 | + - name: Bleeding Edge Docker Hub |
| 62 | + if: github.ref == 'refs/heads/main' |
| 63 | + run: | |
| 64 | + echo "IMAGE_TAG=main" >> $GITHUB_ENV |
| 65 | +
|
| 66 | + # Push nightly image (nightly tag) to registries |
| 67 | + - name: Nightly Docker Hub |
| 68 | + if: github.event_name == 'schedule' |
| 69 | + run: | |
| 70 | + echo "IMAGE_TAG=nightly" >> $GITHUB_ENV |
| 71 | +
|
| 72 | + # Build images |
| 73 | + - name: Build Batbot |
| 74 | + run: | |
| 75 | + docker buildx build \ |
| 76 | + -t kitware/batbot:${{ env.IMAGE_TAG }} \ |
| 77 | + --platform linux/amd64 \ |
| 78 | + --push \ |
| 79 | + . |
| 80 | +
|
| 81 | + # Also push latest image |
| 82 | + - name: Build Batbot |
| 83 | + if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }} |
| 84 | + run: | |
| 85 | + docker buildx build \ |
| 86 | + -t kitware/batbot:latest \ |
| 87 | + --platform linux/amd64 \ |
| 88 | + --push \ |
| 89 | + . |
0 commit comments